1.0.0 • Published 7 years ago
script-loader-async v1.0.0
Async Script Loader
This tiny util allows you to dynamically load a script into the global scope.
Usage
Call loadScript with the three required parameters:
namespacee.g. if the script is accessible viawindow.coolUtilthe namespace iscoolUtilurlcallbackfunction - this recieves the promise which will either resolve or reject and acancelSourcetoken if you need to abort the request.windowobject
Example
// import the util
import loadScript from 'async-script-loader;
// define your callback function
const callbackFn = (response) => {
// if successful the script will be available in the global scope under the namespace you provided
// if unsuccessful the error message is returned
}
// do the thing
loadScript('coolUtil', 'https://coolutil.com', window, callbackFn);1.0.0
7 years ago