-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathloader.min.js
More file actions
7 lines (7 loc) · 1.64 KB
/
loader.min.js
File metadata and controls
7 lines (7 loc) · 1.64 KB
1
2
3
4
5
6
7
/**
* @preserve Tiny-Loader: A small loader that load CSS/JS in best way for page performanceIs.
*
* @version 1.0.1
* @copyright The Youzan Limited [All Rights Reserved]
* @license MIT License (see LICENSE.txt)
*/!function(a,b){"use strict";function f(a){return"complete"===a.readyState||"loaded"===a.readyState}function g(a,c,e){var f=b.createElement("link");f.rel="stylesheet",j(f,e,"css"),f.async=!0,f.href=a,d.appendChild(f)}function h(a,c,e){var f=b.createElement("script");f.charset="utf-8",j(f,e,"js"),f.async=!c.sync,f.src=a,d.appendChild(f)}function i(a,b){var c;a.sheet&&(c=!0),setTimeout(function(){c?b():i(a,b)},20)}function j(b,c,d){function j(){b.onload=b.onreadystatechange=null,b=null,c()}var g="onload"in b,h="css"===d;return!h||!e&&g?void(g?(b.onload=j,b.onerror=function(){b.onerror=null,a._cdnFallback(b)}):b.onreadystatechange=function(){f(b)&&j()}):void setTimeout(function(){i(b,c)},1)}function k(a,b,d,e){function f(){var c=b.indexOf(a);c>-1&&b.splice(c,1),0===b.length&&e()}return a?void(c.test(a)?g(a,d,f):h(a,d,f)):void setTimeout(function(){f()})}function l(a,b,c){var d=function(){c&&c()};if(a=Array.prototype.slice.call(a||[]),0===a.length)return void d();for(var e=0,f=a.length;e<f;e++)k(a[e],a,b,d)}function m(b,c){if(f(b))c();else{var d=1500,e=!1;a.addEventListener("load",function(){e||(c(),e=!0)}),setTimeout(function(){e||(c(),e=!0)},d)}}var c=new RegExp("\\.css"),d=b.head||b.getElementsByTagName("head")[0],e=+navigator.userAgent.replace(/.*(?:AppleWebKit|AndroidWebKit)\/?(\d+).*/i,"$1")<536,n={async:function(a,c){m(b,function(){l(a,{},c)})},sync:function(a,c){m(b,function(){l(a,{sync:!0},c)})}};return a.Loader=n,n}(window,document);