Skip to content
/ xec Public

An async script loader, for the browser, built on Promises.

Notifications You must be signed in to change notification settings

callmecavs/xec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xec

xec on NPM

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(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

  1. Async script loading requires async attribute support.
  2. Promises are required. If needed, polyfill them.

License

MIT. © 2017 Michael Cavalea