Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DanLaufer/d43cd62d4bce5c37e7da922620cf8738 to your computer and use it in GitHub Desktop.
Save DanLaufer/d43cd62d4bce5c37e7da922620cf8738 to your computer and use it in GitHub Desktop.
Drupal 8 - Conditionally remove an attached library
function mytheme_page_attachments_alter(array &$attachments) {
if (in_array('core/jquery', $attachments['#attached']['library'])) {
$index = array_search('core/jquery', $attachments['#attached']['library']);
unset($attachments['#attached']['library'][$index]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment