I have a theme with several template files using <?php print $scripts ?> to load a list of scripts set in the theme's .info file. What's the best way in Drupal 6 to exclude one of the scripts from being loaded in certain template files?

1 Answer 1


I do not think there's a way to really un-set scripts once they've been added, in D6. D7 provides hook_js_alter, but not D6.

Do you have control over the theme? Your best bet would be to remove the scripts from the .info file and only add them as needed by calling drupal_add_js(). Which hooks or preprocessors you need to use to make those calls to drupal_add_js() will be something determined by the purpose of the scripts themselves. But you'll want them added before template_preprocess_page() is called since that's where the $scripts variable is generated.

  • 2
    There's JS Alter which apparently adds the hook (and looking at the code it seems like it would work fine), so I think that's a viable approach
    – Clive
    Aug 6, 2015 at 21:03
  • That looks like a great solution.
    – Aaron
    Aug 6, 2015 at 21:08

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.