8

Drupal 7 adds a new 'weight' option to drupal_add_js so that you can control the order in which Javascript files are added to the page. Is there any way to do this when adding Javascript in .info files?

2

But to answer the actual question, the order that the files are included in the .info file should be the order that they appear on the page.

6

Despite its instructions to not use it for adding JS to every page, hook_init() will allow you to add JS in an more sophisticated way with drupal_add_js().

That said, it is rare that a JS file must be loaded on EVERY page, so there is likely more optimization you can do. Also see the FAPI property #attached for adding JS to a form.

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.