-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlazywrite-min.js
executable file
·2 lines (2 loc) · 3.55 KB
/
lazywrite-min.js
1
2
/*! LazyWrite 1.2.2 (sha1: 0D13ACD1F14A59FAE9DC446FC3F41D55D403C07A) | (c) 2011~2015 Shen Junru. MIT License. | http://github.com/shenjunru/LazyWrite */
(function(e,t,n,r,i){"function"==typeof define&&define.amd?define(function(){return e(t,n,r,i,!1)}):n.LazyWrite=e(t,n,r,i,!1!==n.AUTO_LAZYWRITE)})(function(e,t,n,r,i,s){function P(e){C.errors.push(e)}function H(e,t){return e.appendChild(t)}function B(e){return e.parentNode?e.parentNode.removeChild(e):e}function j(e,t){return e.parentNode.replaceChild(t,e)&&t}function F(e){return n.createElement(e)}function I(){return F("span")}function q(e){var t=F("script");return t.type=e.type,e.src?t.src=e.src:t.text=e.text,t}function R(e,t,n){clearTimeout(n.timeout),n.done=!0,t.onerror=t[l]="",B(e),n===w&&(w=s,J())}function U(t,n){if(n.src){var i={src:n.src};n[l]=function(){var e=r&&n.readyState;!i.done&&(!e||c[e])&&(e==="loaded"&&!i.loaded?(i.loaded=!0,setTimeout(n[l])):R(t,n,i))},n.onerror=function(e){P(i.error=e),R(t,n,i)},setTimeout(function(){H(t,n)}),i.timeout=setTimeout(function(){P("unknow"),R(t,n,i)},60500),w=i}else{try{e(n.text.replace(h,""))}catch(s){P(s)}B(t)}}function z(e){if(e)return w||(E=e.holder),U(e.holder,e.script=q(e.script)),!e.script.src}function W(){for(var e;e=z(N.shift()););return e!==!1&&!w}function X(e,t,n){r?(b.innerHTML="<img />"+t,B(b.firstChild)):b.innerHTML=t;var i=[],s=b.getElementsByTagName("script"),o,u;while(s[0])i.push({script:s[0],holder:j(s[0],I())});while(b.firstChild)y.appendChild(b.firstChild);return S===e?(N=(u=N.n.slice(N.l-N.length).concat(i)).concat(o=N.o),N.n=u,N.o=o,x.parentNode.insertBefore(y,x)):(N=i.concat(o=N),N.n=i,N.o=o,x=y.appendChild(x||I()),n?e.parentNode.insertBefore(y,e.nextSibling):j(e,y)),N.l=N.length,S=e,L&&i.length&&(L=W()),L}function V(e){return e&&e.html&&X(n.getElementById(e.id),e.html)}function $(){while(V(C=T.shift()));L&&!T.length&&(x&&B(x),w=E=S=x=s,n.write=O,n.writeln=M,k=!1)}function J(){L=!0;if(W()){try{C.callback&&C.callback(C.errors)}catch(e){P(e)}$()}}function K(e,t,n){"function"!=typeof n&&(n=s),"function"==typeof t&&(n=t,t=s),t||D('<span id="'+(t=f+u++)+'"></span>'),T.push({id:t,html:e,callback:n,errors:[]})}function Q(e){var t,n,r,i=g+e;g="",G(i)&&(m="");while(r=p.exec(i)){i=i.slice(r.index+r[0].length),n=r[1];if(!r[2]){if(!/\S/.test(i))return g=r[0],m=m||n;if(/=$/.test(r[0])&&/^['"]/.test(i))return g=r[0]+i,m=m||n}else if(!d.test(n)){if(-1===(t=i.indexOf("</"+n+">")))return m=m||n;i=i.slice(t+n.length+3)}}}function G(e){return!m||-1!==e.indexOf("</"+m+">")}function Y(){var e=A.call(arguments,"");if(e)if(Q(e))v+=e;else if(G(e)){e=v+e,m=v=g="";if(k)try{X(E,e,!0)}catch(t){P(t)}else K(e)}else v+=e}function Z(){n.writeln=n.write=Y}var o,u=1,a="text/lazyjs",f="lazy-holder-",l=r?"onreadystatechange":"onload",c={complete:1,loaded:1},h=/^\s*<!--/,p=/<([a-z]+)(?:\s+[a-z]+(?:=(?:'[^']*'|"[^"]*"|[^'">\s]*))?)*\s*(>?)/i,d=/area|base|br|col|frame|hr|img|input|link|meta|param/i,v="",m="",g="",y=n.createDocumentFragment(),b=F("div"),w=s,E=s,S=s,x=s,T=[],N=[],C=s,k=!1,L=!0,A=[].join,O=n.write,M=n.writeln,_=t.onerror,D=O.apply?function(){O.apply(n,arguments)}:O;return t.onerror=function(e,n){w&&n===w.src&&!w.error&&P(e),_&&_.apply(t,arguments)},i&&Z(),o={write:D,prepare:Z,render:K,process:function(){if(k)return;k=!0,o.prepare(),$()},findScripts:function(e){e=e||a;var t=n.getElementsByTagName("script"),r=t.length-1,i=[],s,o,l;for(;-1<r;r--)e===t[r].type&&i.push(t[r]);for(;s=i.pop();){j(s,o=I());if(l=s.getAttribute("src"))H(b,F("script")).src=l;H(b,s),K(b.innerHTML,o.id=f+u++),b.innerHTML=""}}}},function(){eval.apply(window,arguments)},window,document,/*@cc_on!@*/!1);