Loading...
 
Skip to main content

Add external JavaScript

This is a short Tutorial.


You can do it in various ways. Some devs usually use styles/custom.js (or styles/mytheme/custom.js) to do most of their custom JS stuff, mainly so they can use a proper editor that checks for typos etc (and edits via s/ftp etc)

Or you can use the Custom JS pref: header_custom_js (which actually appears after the JS includes).

In there you can use the jQuery $.getScript command to load the 3rd party files - like this:

Script to include
Copy to clipboard
$(document).ready( function () { $.getScript("files/some-fancy-library-file.js", function () { // Add the code to execute once the library has loaded here // .... }); });


More here: http://api.jquery.com/jQuery.getScript/

Add external js script

Collapse/expand modules below