Skip to content

Ensure a page has the libraries you need, or load 'em from a CDN.

Notifications You must be signed in to change notification settings

elucidata/ensure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ensure

Takes the simplest approach to ensure a page has the libraries you need, or loads 'em from a CDN. Good for use in components, or embedded scripts.

ensure('jquery', function(err){
  if(err) throw err;

  // jQuery is ready, do something with it.
})
ensure('jquery', 'underscore', 'backbone', function(err){
  if(err) throw err;

  // It's all loaded, go for it!
})

Comes with support for:

  • AngularJS
  • Backbone
  • Hammer
  • jQuery
  • jQuery UI
  • Underscore
  • WebFont
  • Zepto

For libraries not built in, just pass in a function that returns a url string if the script needs to be loaded. (shown in coffeescript)

blam= -> blam ? "//darthapo.github.com/blam.js/blam.min.js"

ensure 'jquery', blam, (err)->
  throw err if err?

About

Ensure a page has the libraries you need, or load 'em from a CDN.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published