-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy pathscript.min.js
More file actions
10 lines (10 loc) · 2.21 KB
/
script.min.js
File metadata and controls
10 lines (10 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
/*!
* $script.js JS loader & dependency manager
* https://github.com/ded/script.js
* (c) Dustin Diaz 2014 | License MIT
*/
/*!
* With permissions from @ded to enable this module load css files asynchrnously as well
* $script.js JS dependency manager & CSS loader
*/
(function(n,t){typeof module!="undefined"&&module.exports?module.exports=t():typeof define=="function"&&define.amd?define(t):this[n]=t()})("$script",function(){var o="script",v="undefined";function l(n,t){for(var i=0,r=n.length;i<r;++i)if(!t(n[i]))return nt;return 1}function a(n,t){l(n,function(n){return!t(n)})}function n(o,s,h){function w(n){return n.call?n():r[n]}function v(){if(!--b){r[c]=1,p&&p();for(var n in t)l(n.split("|"),w)&&!a(t[n],w)&&(t[n]=[])}}o=o[i]?o:[o];var y=s&&s.call,p=y?s:h,c=y?o.join(""):s,b=o.length;return setTimeout(function(){a(o,function n(t,i){if(t===null)return v();if(t=!i&&t.indexOf(".js")===-1&&!/^https?:\/\//.test(t)&&f?f+t+".js":t,u[t])return c&&(k[c]=1),u[t]==2?v():setTimeout(function(){n(t,!0)},0);u[t]=1,c&&(k[c]=1),e(t,v)})},0),n}function e(n,t){var r=n.toString()===n,i=n.nodeType&&n||r&&s.createElement(tt[(n.match(/\.(js|css)$/i)||["",""])[1]]),f=i.nodeName.toLowerCase(),e;if(f!=v){i.onload=i.onerror=i[b]=function(){i[w]&&!/^c|loade/.test(i[w])||e||(i.onload=i[b]=null,e=1,u[n]=2,t&&t())};switch(f){case o:i.type="text/javascript",i.async=r?1:!1,n=r?n:d,i.src=c?n+(n.indexOf("?")===-1?"?":"&")+c:n;break;case"link":i.type="text/css",i.rel="stylesheet",i.href=n}r&&y.insertBefore(i,y.lastChild)}}var s=document,y=s.getElementsByTagName("head")[0],p=s.getElementsByTagName(o),h=p[p.length-1],d=h.src,g=h.getAttribute("setup-main"),it="string",nt=!1,i="push",w="readyState",b="onreadystatechange",r={},k={},t={},u={},f,c,rt=/^(\.(?=\/)|[^\.\/]+?\.[a-z]{2,4})/i,tt={js:o,css:"link","":v};return console.log("s: "+f),n.get=function(n,t){e(String(n),t)},n.order=function(t,i,r){(function u(f){f=t.shift(),t.length?n(f,u):n(f,i,r)})()},n.path=function(n){f=n},n.urlArgs=function(n){c=n},n.ready=function(n,u,f){n=n[i]?n:[n];var e=[];return!a(n,function(n){r[n]||e[i](n)})&&l(n,function(n){return r[n]})?u():!function(n){t[n]=t[n]||[],t[n][i](u),f&&f(e)}(n.join("|")),this},n.done=function(n){this([null],n)},e(h,function(){e(g)}),n})