FOFTemplateUtils::addJS
Add a JS script file to the page generated by the CMS.
There are three combinations of defer and async (see http://www.w3schools.com/tags/att_script_defer.asp): * $defer false, $async true: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing) * $defer true, $async false: The script is executed when the page has finished parsing. * $defer false, $async false. (default) The script is loaded and executed immediately. When it finishes loading the browser continues parsing the rest of the page. When you are using $defer = true there is no guarantee about the load order of the scripts. Whichever script loads first will be executed first. The order they appear on the page is completely irrelevant.
Signature
public function addJS(string
$path,
[boolean
$defer = false,
[boolean
$async = false]] )
Parameters
-
$path
- A fancy path definition understood by parsePath
-
$defer
- Adds the defer attribute, meaning that your script
-
$async
- Adds the async attribute, meaning that your script
Returns
- void