A super simple JavaScript loader
How to use:
Create an instance of Unbox
const Unbox = new Unbox;
Load a script
Unbox.require('/js/quill.js', _ => {
if (Quill instanceof Object) {
quill = new Quill(document.getElementById('quill');
}
});
You can use require multiple times with the same source, and it'll resolve the callbacks when the script is loaded
Load one or more scripts when the browser is idle
Unbox.lazyRequire('/js/quill.js');
Unbox.lazyRequire([
'/js/monaco/min/vs/loader.js',
'/js/quill.js'
]);
Check if one or more script is loaded
Unbox.loaded('/js/quill.js');
Unbox.loaded([
'/js/monaco/min/vs/loader.js',
'/js/quill.js'
]);