A tiny cross-browser css, javascript- and module-loader.
minc.js is a lightweight cross-browser Javascript/CSS file- and module-loader. (~800 bytes, minified and gzipped) making it super-easy to dynamically embed your css-files, javascripts and/or initialize custom modules.
You simply pass an array with your files to Minc
. That's it.
If you load your files via a CDN, you might optionally add another array with fallbacks.
Minc(
[ // load a bunch of files
'//code.jquery.com/jquery-2.1.0.js',
'//mycdn.com/my-cool-lib.min.js',
'//mycdn.com/my-cool-css.min.css'
],
[ // optional: set up alternatives, if the CDN is down...
'lib/jquery-2.1.0.js',
'src/myCoolApp.min.js',
'src/my-cool-css.min.css'
]
).done(function($, myApp) { // callback, when files are loaded
// entry point
$('body').addClass('success');
myApp.init();
});
$ bower install minc
minc.js runs in every browser on every device (tested with all devices/browsers at browserstack.com).
minc.js supports the basics of the AMD-structures, thus you might use your own modules.
See an AMD example-module.
If you're not familiar with modular JavaScript, read this.
If you just want to load AMD-supported libraries without using them inside the module-callback, add an additional empty object as local-context to Minc
.
Minc([scripts], [fallbacks], {});