0

When using the drupal_add_js function, should I see the script I am loading appear in the list of scripts being loading in the header of the generated html page? I thought I should, but I don't - so perhaps my understanding of this function is wrong. Can someone clarify what is suppose to happen.

Just as note I have verified that the path to the script is correct so I know that isn't the issue.

Thanks.

4
  • 4
    Could you post the code you're using?
    – Clive
    Commented Jun 24, 2013 at 16:31
  • 1
    if you have turned on javascript aggregation/optimization, then no, you won't see the individual file, but its content will be included in the file drupal builds. it's always a good idea to clear these caches when new files are added. of course, if you aren't doing this aggregation/optimization, then yes, they should show up.
    – Jimajamma
    Commented Jun 24, 2013 at 16:33
  • I don't have aggregation turned on and do clear the cache every time I make a change. But my understanding is correct that it should be visible. Now I just need to figure out why it isn't working.
    – user5013
    Commented Jun 24, 2013 at 16:56
  • @user5013 please post your code
    – CR47
    Commented Jun 24, 2013 at 18:46

1 Answer 1

0

With drupal_add_js() you can set the scope to either header or footer, specify the group the script is loaded into, and give the script a weight relative to that group. Scripts are loaded by scope > group > weight, where a lower weight will be loaded before a higher weight.

If you have aggregation turned on in /admin/config/development/performance, the script will be combined with others with the same scope & group, and ordered by weight.

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.