-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathcsscritic.js
More file actions
66 lines (57 loc) · 1.87 KB
/
csscritic.js
File metadata and controls
66 lines (57 loc) · 1.87 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* CSS Critic loader
*
* Just include
* <script src="csscritic.js"></script>
* and you are good to go.
*/
/*jslint evil: true */
(function () {
"use strict";
var cssDependencies = [
'src/browser/niceReporter.css'
],
jsDependencies = [
'node_modules/rasterizehtml/dist/rasterizeHTML.allinone.js',
'node_modules/imagediff/imagediff.js',
'node_modules/ayepromise/ayepromise.js',
'src/boot/scope.js',
'src/browser/pageNavigationHandlingFallback.js',
'src/browser/niceReporter.js',
'src/browser/browserRenderer.js',
'src/browser/indexedDbStorage.js',
'src/browser/jobQueue.js',
'src/browser/urlQueryFilter.js',
'src/browser/fallbackFilter.js',
'src/util.js',
'src/reporting.js',
'src/regression.js',
'src/main.js',
'packageVersion.js',
'src/boot/browser.js'
];
var getCurrentScript = function () {
return document.currentScript || (function() {
var scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();
};
var getBasePath = function () {
var script = getCurrentScript(),
src = script.attributes.src.value;
return src.substring(0, src.lastIndexOf('/') + 1);
};
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);
});
}());