[](https://badge.fury.io/js/unistar-async-script-loader) [](https://opensource.org/licenses/mit-license.php) [![TypeS
npm install unistar-async-script-loaderbash
npm install unistar-async-script-loader
`
Usage
`javascript
AsyncScriptLoader.script('./script/a.js', () => console.log('destroy a'))
.script('./script/b.js').wait()
.script('./script/c.js')
.func(() => console.log('I"m one-off function'))
.run();
AsyncScriptLoader.destory('./script/a.js')
.run();
`
The scripts will be appended to document.body.
API
`typescript
/**
* the API class
*
* the functions are divided into 2 modes:
* script(), func(), wait() and destory() run in record mode.
* they will simply push a task in the running queue of the LoadingChain,
* and they does not perform the actural loading and destory task.
*
* run() runs in execute mode.
* it will asynchronously execute the tasks in the running queue.
* tasks in the queue are parallel executed, unless a wait() call is specified in the record mode.
* no more API invocations to the LoadingChain can be performed after the run() method.
*/
class AsyncScriptLoader {
/**
* record mode.
* record a script to be load.
*
* @param {string} script - the script to load.
* string parameter indicates the url of the script, and, when loaded, will append a