Skip to main content
Topic: How do I know if pre_javascript_output is being called for deferred? (Read 1625 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How do I know if pre_javascript_output is being called for deferred?

This hook gets called twice now once for deferred and once non-deferred.  No flag is sent to the hook though, so when I call addInlineJavascript with deferred = true it adds the javascript twice at the end of the page.  How do I determine if the call is for deferred code or not so the double code doesn't happen?

Re: How do I know if pre_javascript_output is being called for deferred?

Reply #1

I would not use pre_javascript_output to add javascript, if your only goal is to insert some javascript, then for example integrate_load_theme is a better option.
pre_javascript_output goal is to give addons the ability to manipulate the javascript files (e.g. replace all the URLs from local to CDN) just before sending it to the template, not to be used to add new javascript to the template.

Yes, I know it's not documented... O:-)
Bugs creator.
Features destroyer.
Template killer.

Re: How do I know if pre_javascript_output is being called for deferred?

Reply #2

Thanks.  I'll give it a look.  You might think about passing the deferred variable along in the hook anyway given it is called twice under slightly different circumstances.