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 Feb 21 '19 at 9:42
  • @leymannx, the question itself seems clear to me. Minified or not doesn't really matter for the answer. – 4k4 Feb 21 '19 at 10:23

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, privacy policy and cookie policy

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