Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/callmecavs/xec
An async script loader, for the browser, built on Promises.
https://github.com/callmecavs/xec
async script-loader
Last synced: 1 day ago
JSON representation
An async script loader, for the browser, built on Promises.
- Host: GitHub
- URL: https://github.com/callmecavs/xec
- Owner: callmecavs
- Created: 2016-08-12T22:08:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-26T01:21:56.000Z (almost 8 years ago)
- Last Synced: 2025-01-08T10:43:00.899Z (2 days ago)
- Topics: async, script-loader
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# xec
[![xec on NPM](https://img.shields.io/npm/v/xec.svg?style=flat-square)](https://www.npmjs.com/package/xec)
An async script loader, for the browser, built on Promises.
> Pronounced "exec".
## Install
```
npm i xec --save
```## API
xec exports a singleton, and _won't load the same source twice_.
It exposes the following API:
* [one](#onesource)
* [many](#manysources)### .one(source)
```javascript
import { one } from 'xec'one('path/one.js')
.then(() => console.log('Script loaded and executed.'))
.catch(() => console.log('Something went wrong.'))
```### .many(sources)
```javascript
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
1. Async script loading requires [`async`](http://caniuse.com/#search=async) attribute support.
2. [Promises](http://caniuse.com/#search=promises) are required. If needed, [polyfill](https://github.com/stefanpenner/es6-promise) them.## License
[MIT](https://opensource.org/licenses/MIT). © 2017 Michael Cavalea