Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top