Javascript & Jquery

All Javascript is bundled and minified into one file. For this reason you are no longer able to use jQuery inside of HTMLModules. All Javascript and jQuery code is required to be added via the Javascript editor.

3rd-party Script Tags

3rd-party code that requires HEAD tag placement

If a 3rd-party script needs to go in the head tag you can add it to the Google Tag Manager section or use the following script inside the Javascript Editor to inject it in the head tag:

This will create a script tag and place it after the first script tag in the head tag.

JS Script Tag:
var headScript = document.createElement('script');
headScript.src = ' URL ';
headScript.async = true;
var entry = document.getElementsByTagName('script')[0];
entry.parentNode.insertBefore(headScript, entry);
3rd-party code that requires or uses jQuery (before closing BODY tag)

If a 3rd-party script relies on jQuery (i.e. FancyBox), the actual code will either need to be placed inside the Javascript Editor or if too long/large be appended to the closing body tag. You can do the latter via this code:

This will create a script tag and place it at the bottom of the DOM before the closing body tag so it loads after our minified JS.

JS Script Tag:
var injectScript = document.createElement('script');
injectScript.src = ' URL ';
injectScript.async = true;
document.body.insertBefore(injectScript, null);