load-script
Syntax
load-script: "url" [every (time)] [after (time)][, (class)...];
url = The url of the JavaScript script file to load.
New files loaded will only be added once. Ie. new files won't load twice if this action command has already been run.
The following simple example will load a third-party PayPal script only after a certain div is drawn on the page:
#payPalWrapper:draw {
load-script: "https://www.paypal.com/sdk/js?validParameters=goHere";
}
Even if this div is drawn multiple times, the script will not be retrieved from the server more than once.
When a web page is first loaded, all script tags on the page are scanned and the srcs stored. You will not be able to load the same script more than once.
Note: This command only supports JavaScript scripts at the moment, as this is the most common usage. Let us know if you have a need for any other type of script.
Note for versions prior to 2.4.0: The afterLoadScript event was not working predictably and was running before the script had been fully loaded. This should be fixed now but if you have been using it you may need to check out your code to make sure it still works.