-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconditionizr.min.js
9 lines (9 loc) · 1.25 KB
/
conditionizr.min.js
1
2
3
4
5
6
7
8
9
/*!
* Conditionizr v4.0.0
* Detecting front-end environments and conditionally loading assets
* https://github.com/conditionizr/conditionizr
* Authors: @toddmotto and @markgdyr
* Copyright 2013
* MIT licensed
*/
window.conditionizr=function(a,b,c){"use strict";var d,e={},f=b.head||b.getElementsByTagName("head")[0],g=function(a,c,g){var h=(g?"":d||"")+a+("script"===c?".js":".css");if(g||e[a])switch(c){case"script":var i=b.createElement("script");i.src=h,f.appendChild(i);break;case"style":var j=b.createElement("link");j.href=h,j.rel="stylesheet",f.appendChild(j);break;case"class":b.documentElement.className+=" "+a}};return e.add=function(a,b,d){var f=a.toLowerCase();if(e[f]!==c)throw new Error("Test "+f+" already exists");if(d||(d=b),e[f]=d(),!(b instanceof Array))throw new Error("Dependencies must be an array");for(var h=0;h<b.length;h++){var i=b[h];g(f,i)}},e.config=function(a){var b=a||{};d=b.assets||"";var c=b.tests;for(var e in c)for(var f=c[e],h=0;h<f.length;h++){var i=f[h];g(e,i)}},e.on=function(a,b){var c=a.toLowerCase(),d=/^!/;if(d.test(c)){var f=c.replace(d,"");e[f]||b()}e[c]&&b&&b()},e.load=e.polyfill=function(a,b){for(var c=/\.js$/.test(a)?"script":"style",d=a.replace(/\.(js|css)$/,""),f=0;f<b.length;f++)e[b[f]]&&g(d,c,!0)},e}(window,document);