forked from cburgmer/csscritic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsscritic.js
46 lines (40 loc) · 1.3 KB
/
csscritic.js
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
41
42
43
44
45
46
/*
* CSS Critic loader
*
* Just include
* <script src="csscritic.js"></script>
* and you are good to go.
*/
(function () {
var thisFileName = 'csscritic.js',
cssDependencies = [
'src/browser/basichtmlreporter.css'
],
jsDependencies = [
'node_modules/rasterizehtml/dist/rasterizeHTML.allinone.js',
'node_modules/imagediff/imagediff.js',
'src/browser/basichtmlreporter.js',
'src/browser/browserrenderer.js',
'src/browser/domstorage.js',
'src/utils.js',
'src/csscritic.js'
];
var getBasePath = function () {
var script = document.querySelector('script[src*="' + thisFileName + '"]'),
src = script.attributes.src.value;
return src.substring(0, src.indexOf(thisFileName));
};
var loadCssDependency = function (path) {
document.write('<link rel="stylesheet" href="' + path + '">');
};
var loadJsDependency = function (path) {
document.write('<script src="' + path + '"></script>');
};
var basePath = getBasePath();
cssDependencies.forEach(function (path) {
loadCssDependency(basePath + path);
});
jsDependencies.forEach(function (path) {
loadJsDependency(basePath + path);
});
}());