An async script loader, for the browser, built on Promises.
Pronounced "exec".
npm i xec --save
xec exports a singleton, and won't load the same source twice.
It exposes the following API:
import { one } from 'xec'
one('path/one.js')
.then(() => console.log('Script loaded and executed.'))
.catch(() => console.log('Something went wrong.'))
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.'))
- Async script loading requires
async
attribute support. - Promises are required. If needed, polyfill them.
MIT. © 2017 Michael Cavalea