-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathloader.js
More file actions
40 lines (36 loc) · 929 Bytes
/
loader.js
File metadata and controls
40 lines (36 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Use it for developing CSSKit, otherwise use build/CSSKit.js
*/
var exports = {};
function require(path) {
path = path.replace(/^\.\//, '');
if (!exports[path]) {
window.console && console.warn(path, 'is missing. Most likely just a mutual inclusion.');
}
return exports;
}
loadScripts(['../src/files'], function() {
loadScripts(exports.files, function() {
delete exports.files;
window.CSSOM = exports;
});
});
/**
* Simplified version of https://gist.github.com/603980
* @param {Array.<string>} paths
* @param {Function} callback
*/
function loadScripts(paths, callback) {
var length = paths.length;
for (var i = 0, ii = length; i < ii; i++) {
var script = document.createElement('script');
script.async = false;
script.src = '../lib/' + paths[i] + '.js';
script.onload = function() {
if (--length === 0) {
callback();
}
};
document.documentElement.appendChild(script);
}
}