Use pre.js to load your JS and CSS files efficiently. Perfect for mobile apps and sites where 3G can often fail.
- Petite: only 2.5kb gzipped.
- Resilient: Auto-retries downloads when they fail.
- Efficient: Downloads files in parallel.
$ bower install --save pre-js $ npm install --save pre-js
Create a file like
load.js, which contains pre.js and your loader code.
Use whatever build tool you prefer to do this for you. This gets you a small
<4kb loader you can use as a "gateway" to the rest of your app.
/* load.js */var Pre = ;;
See pre.js's inline comments for more info. Here's a quick reference of the API:
For more complicated things:
Better with CoffeeScript, if that's your thing:
Precss 'style.css'js 'jquery.js'-> jQuery?js 'app.js'-> App?then -> Appstart
pre.js © 2014, Rico Sta. Cruz. Released under the MIT License.
Includes code from yepnope.js, released under WTFPL. © 2012 Alex Sexton & Ralph Holzmann.