I have a whole bunch of modules that add .js scripts to the head using drupal_add_js. I want to make sure one of the scripts appears above all others. To that affect I have added a weight value to the options:
drupal_add_js(some_GTM_script.js,
array(
'type' => 'inline',
'scope' => 'head_scripts',
'weight' => 99,
));
But nothing changes. I've tried 99, -99, 0, 10, but not matter what the script's position doesn't change.
Would anyone know how to do this?
Use a negative weight within the proper
scopeandgroup.So, if 'head_scripts' is the first region to appear on the page, you still have to define the script 'group', ie. library scripts appear before theme scripts.
To enforce the priority of your script you may need to use
JS_DEFAULT - x, or evenJS_LIBRARY - xif you want it to be included before anything, even jQuery etc.