The objective is to exclude certain javascript files from some sections of the website.

I exclude javascript and css files in this way in the template.php file of the theme:

function phptemplate_preprocess_page(&$vars) {    
  $scripts = drupal_add_js();
  // unset($scripts['module']['sites/default/files/js/jquery-min.js']);
  $vars['scripts'] = drupal_get_js('header', $scripts);    

However it seems that jquery_update preprocess is executed after template.php, so it overrides my changes:

function jquery_update_preprocess_page(&$variables) {
      $variables['scripts'] = drupal_get_js('header', $scripts);       

The code is located in jquery_update.module

How would be the best approach to resolve this?

I would prefer not to hack or disable the jquery_update.module code if possible.

Any alternative ways to exclude javascript files that doesn't involve touching the template.php file would also fix my problem I think.

1 Answer 1


JSAlter module for D6 should solve your problem..

Project page says

This module will not be ported to Drupal 7, because Drupal 7 core natively includes a hook_js_alter(). Note that the signature and when the hook is invoked is slightly different in Drupal 7 core than it is in this module.

This module adds a hook_js_alter() hook that other modules can use to modify the javascript that gets output to the page. The module provides no end-user functionality, but other modules can use this module as a dependency. Check out the JS Registry, JS Debug Helper, and jQuery Form Update modules for examples.

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.