Methods to dynamically load JavaScript, CSS, and Images.
Before anything taking its part, you should install node and "cortex".
Visit http://nodejs.org, download and install the proper version of nodejs.
var asset = require('asset');
asset[type](src, callback);
Preloads an image. NOTICE that, asset.image
will not inject the image into the document.
Returns HTMLImageElement
the image element.
var img = asset.image('http://domain.com/icon.png', function(){
div.appendChild(img);
});
- src
String
The location of the JavaScript file to load. - callback
function()
A function that will be invoke when loaded.
Injects a script tag into the head section of the document, pointing to the src specified.
Returns HTMLScriptElement
the script node of the JavaScript which is tried to load into the document.
Injects a link node of stylesheet in the page.
Returns HTMLLinkElement
the link node.