2

I'm using a jquery carousel on my site and getting some errors on some pages. My jquery guru said the cause of the problem is that currently jquery.js gets included after other javascript includes.

Making the jquery.js the first include will fix the problem according to him. How do I change the order of the javascript includes?

2
  • 1
    If you do a view source, where is jquery.js? I don't recall not seeing it first.
    – mpdonadio
    Commented Jan 17, 2012 at 1:03
  • in 7th place, after jquery.once.js?v=1.2, drupal.js, admin_devel.js, memcache.js, video.js and extlink.js
    – uwe
    Commented Jan 17, 2012 at 1:08

1 Answer 1

6

Use hook_js_alter to change the order of js presentation.

For example, edit your theme's template.php:

function youtheme_js_alter(&$javascript) {

  $javascript['misc/jquery.js']['group'] = -500;

  $javascript['misc/jquery.js']['weight'] = -500;

}
1
  • 2
    thanks. I found the problem, it was caused by a malformed drupal_add_js() function which caused the order of the includes to get messed up. Here is the post for future reference: api.drupal.org/api/drupal/includes--common.inc/function/… Your answer pointed in the right direction (weights), so I'll accept it.
    – uwe
    Commented Jan 17, 2012 at 5:00

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.