Is there a way to include a javascript/jquery on every page?

Comments

TapocoL’s picture

Use hook_menu. It is only on all non-cached pages when enabled. Since cached pages already have it included, no need to worry about that. But, you will need to clear cache if you have it enabled.

function mymodule_menu($may_cache) {
  drupal_add_js('misc/myjquery.js');

  // Other hook_menu info
}

-Craig Jackson
-Web Developer

anztenney’s picture

I knew it would be something simple, I just couldn't find anything about it. That worked great.

digitalpiku’s picture

I use this,

function mymodule_init(){
$path = drupal_get_path('module', 'mymodule');
drupal_add_js($path .'/activeshare.js', 'module', 'header', TRUE);
}

jaypan’s picture

The original method was for Drupal 5 - it won't work on Drupal 6. Your method is correct for Drupal 6.

Contact me to contract me for D7 -> D10/11 migrations.