I need to remove a JavaScript file added from a module through a theme. How can I achieve this?

  • Hey Ravi, what do you mean by "when we minified the file"? Is this some dynamic condition? Do you know that for example drupal.org/project/advagg is able to automatically minify all CSS/JS assets? And that you when this is a custom theme simply can add the already minified file instead? Is this a custom theme? Or a contrib/core theme your are talking about? Please update your question for clarification. Please don't clarify in the comments.
    – leymannx
    Commented Feb 21, 2019 at 9:42
  • @leymannx, the question itself seems clear to me. Minified or not doesn't really matter for the answer.
    – 4uk4
    Commented Feb 21, 2019 at 10:23

1 Answer 1


Implement hook_library_info_alter:


 * Implements hook_library_info_alter().
function mytheme_library_info_alter(&$libraries, $extension) {
  if ($extension === 'some_module') {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.