xec
v0.1.0
Published
An async script loader, for the browser, built on Promises.
Downloads
25
Maintainers
Readme
xec
An async script loader, for the browser, built on Promises.
Pronounced "exec".
Install
npm i xec --saveAPI
xec exports a singleton, and won't load the same source twice.
It exposes the following API:
.one(source)
import { one } from 'xec'
one('path/one.js')
.then(() => console.log('Script loaded and executed.'))
.catch(() => console.log('Something went wrong.')).many(sources)
import { many } from 'xec'
const sources = [
'path/one.js',
'path/two.js'
]
many(sources)
.then(() => console.log('All scripts loaded and executed.'))
.catch(() => console.log('Something went wrong.'))Browser Support
- Async script loading requires
asyncattribute support. - Promises are required. If needed, polyfill them.
License
MIT. © 2017 Michael Cavalea
