Skip to content
Browse files

LABjs 2.0b

  • Loading branch information...
1 parent 98961f3 commit 2fc75fe3656bcd73177c7083079b3cdacaa69582 @getify getify committed May 23, 2011
Showing with 16 additions and 1 deletion.
  1. +5 −0 next/LAB-debug.min.js
  2. +5 −0 next/LAB.js
  3. +5 −0 next/LAB.min.js
  4. +1 −1 next/LAB.src.js
View
5 next/LAB-debug.min.js
@@ -0,0 +1,5 @@
+/*! LAB.js (LABjs :: Loading And Blocking JavaScript)
+ v2.0b (c) Kyle Simpson
+ MIT License
+*/
+(function(j){var Q=j.$LAB,q="UseLocalXHR",C="AlwaysPreserveOrder",y="AllowDuplicates",D="CacheBust",l="Debug",E="BasePath",F=/^[^?#]*\//.exec(location.href)[0],G=/^\w+\:\/\/\/?[^\/]+/.exec(F)[0],i=document.head||document.getElementsByTagName("head"),t=!(XMLHttpRequest||ActiveXObject),R=(j.opera&&Object.prototype.toString.call(j.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),k=function(){},H=k,u=document.createElement("script"),v=u.async===true,I=typeof u.preload=="boolean",J=I||(u.readyState&&u.readyState=="uninitialized");if(j.console&&j.console.log){if(!j.console.error)j.console.error=j.console.log;k=function(a){j.console.log(a)};H=function(a,c){j.console.error(a,c)}}if(t)k("LABjs warning: XHR disabled after init failure.");function K(a){return Object.prototype.toString.call(a)=="[object Function]"}function L(a){return Object.prototype.toString.call(a)=="[object Array]"}function M(a,c){var b=/^\/\/[^\/]/,d=/^\w+\:\/\//;if(b.test(a)){a=location.protocol+a}else if(!d.test(a)){if(c!=null){c=(d.test(c))?c:M(c,c[0]=="/"?G:F);a=c+a}}return a}function w(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function S(a){var c=false;for(var b=0;b<a.scripts.length;b++){if(a.scripts[b].ready&&a.scripts[b].exec_trigger){c=true;a.scripts[b].exec_trigger();a.scripts[b].exec_trigger=null}}return c}function x(a,c,b,d){a.onload=a.onreadystatechange=function(){if((a.readyState&&a.readyState!="complete"&&a.readyState!="loaded")||c[b])return;a.onload=a.onreadystatechange=null;d()}}function N(a,c,b){b.ready=b.finished=true;for(var d=0;d<b.finished_listeners.length;d++){setTimeout(b.finished_listeners[d],0)}b.ready_listeners=[];b.finished_listeners=[]}function T(d,e,f,h,g){setTimeout(function(){if("item"in i){if(!i[0]){setTimeout(arguments.callee,25);return}i=i[0]}var a=document.createElement("script"),c=e.real_src;if(e.type)a.type=e.type;if(e.charset)a.charset=e.charset;if(!f.preload&&!v){if(d[l])k("start script load: "+c);if(v)a.async=false;x(a,h,"finished",g);a.src=c;i.insertBefore(a,i.firstChild)}else if(J){if(d[l])k("start script preload: "+c);h.elem=a;if(I){a.preload=true;a.onpreload=g}else{a.onreadystatechange=function(){if(a.readyState=="loaded")g();a.onreadystatechange=null}}a.src=c}else if(v){if(d[l])k("start script load (ordered async): "+c);a.async=false;x(a,h,"finished",g);a.src=c;i.insertBefore(a,i.firstChild)}else if(c.indexOf(G)==0&&d[q]){var b=XMLHttpRequest?new XMLHttpRequest():(ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):null);if(d[l])k("start script preload (xhr): "+c);b.onreadystatechange=function(){if(b.readyState==4){b.onreadystatechange=function(){};h.text=b.responseText+"\n//@ sourceURL="+c;g()}};b.open("GET",c);b.send()}else{if(d[l])k("start script preload (cache): "+c);a.type="text/cache-script";x(a,h,"ready",function(){i.removeChild(a);g()});a.src=c;i.insertBefore(a,i.firstChild)}},0)}function O(){var m={},U=!v&&(J||!R),r=[],s={},p;m[q]=!t;m[C]=false;m[y]=false;m[D]=false;m[l]=false;m[E]="";function V(a,c,b,d){function e(){N(c,b,d);f=null}if(s[c.src].finished)return;if(!a[y])s[c.src].finished=true;var f=d.elem||document.createElement("script");if(c.type)f.type=c.type;if(c.charset)f.charset=c.charset;x(f,d,"finished",e);if(d.elem){d.elem=null}else if(d.text){f.onload=f.onreadystatechange=null;f.text=d.text}else{f.src=c.real_src}i.insertBefore(f,i.firstChild);if(d.text){e()}}function W(c,b,d){var e,f,h=function(){b.ready_cb(b,d,function(){V(c,b,d,e)})},g=function(){b.finished_cb(b,d)};b.src=M(b.src,c[E]);b.real_src=b.src+(c[D]?(/\?.*$/.test(b.src)?"&_":"?_")+~~(Math.random()*1E9)+"=":"");if(!s[b.src])s[b.src]={items:[],finished:false};f=s[b.src].items;if(c[y]||f.length==0){e=f[f.length]={ready:false,finished:false,ready_listeners:[h],finished_listeners:[g]};T(c,b,d,e,(d.preload)?function(){e.ready=true;for(var a=0;a<e.ready_listeners.length;a++){setTimeout(e.ready_listeners[a],0)}e.ready_listeners=[]}:function(){N(b,d,e)})}else{e=f[0];if(e.finished){setTimeout(g,0)}else{e.finished_listeners.push(g)}}}function z(){var f,h=w(m,{}),g=[],o=0,A=false,n;function X(a,c,b){if(h[l])k("script preload finished: "+a.real_src);a.ready=true;a.exec_trigger=b;B()}function Y(a,c){if(h[l])k("script execution finished: "+a.real_src);a.ready=a.finished=true;a.exec_trigger=null;for(var b=0;b<c.scripts.length;b++){if(!c.scripts[b].finished)return}c.finished=true;B()}function B(){while(o<g.length){if(K(g[o])){if(h[l])k("$LAB.wait() executing: "+g[o]);try{g[o]()}catch(err){if(h[l])H("$LAB.wait() error caught: ",err)}}else if(!g[o].finished){if(S(g[o]))continue;break}o++}if(o==g.length){A=false;n=false}}function P(){if(!n||!n.scripts){g.push(n={scripts:[],finished:true,preload:U&&A})}}f={script:function(){P();A=true;for(var e=0;e<arguments.length;e++){(function(a,c){if(!L(a)){c=[a]}for(var b=0;b<c.length;b++){P();a=c[b];if(K(a))a=a();if(!a)continue;if(L(a)){var d=[].slice.call(a);d.push(b,1);c.splice.call(c,d);b--;continue}if(typeof a=="string")a={src:a};a=w(a,{ready:false,ready_cb:X,finished:false,finished_cb:Y});n.finished=false;n.scripts.push(a);W(h,a,n);if(h[C])f.wait()}})(arguments[e],arguments[e])}return f},wait:function(){if(arguments.length>0){for(var a=0;a<arguments.length;a++){g.push(arguments[a])}n=g[g.length-1]}else n=false;B();return f}};return{script:f.script,wait:f.wait,setOptions:function(a){w(a,h);h[q]=h[q]&&!t;return f}}}p={setGlobalDefaults:function(a){w(a,m);m[q]=m[q]&&!t;return p},setOptions:function(){return z().setOptions.apply(null,arguments)},script:function(){return z().script.apply(null,arguments)},wait:function(){return z().wait.apply(null,arguments)},queueScript:function(){r[r.length]={type:"script",args:[].slice.call(arguments)};return p},queueWait:function(){r[r.length]={type:"wait",args:[].slice.call(arguments)};return p},runQueue:function(){var a=p,c=r.length,b=c,d;for(;--b>=0;){d=r.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){j.$LAB=Q;return p},sandbox:function(){return O()}};return p}j.$LAB=O();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);
View
5 next/LAB.js
@@ -0,0 +1,5 @@
+/*! LAB.js (LABjs :: Loading And Blocking JavaScript)
+ v2.0b (c) Kyle Simpson
+ MIT License
+*/
+(function(p){var N=p.$LAB,n="UseLocalXHR",A="AlwaysPreserveOrder",v="AllowDuplicates",B="CacheBust",C="BasePath",D=/^[^?#]*\//.exec(location.href)[0],E=/^\w+\:\/\/\/?[^\/]+/.exec(D)[0],h=document.head||document.getElementsByTagName("head"),w=!(XMLHttpRequest||ActiveXObject),O=(p.opera&&Object.prototype.toString.call(p.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),r=document.createElement("script"),s=r.async===true,F=typeof r.preload=="boolean",G=F||(r.readyState&&r.readyState=="uninitialized");function H(a){return Object.prototype.toString.call(a)=="[object Function]"}function I(a){return Object.prototype.toString.call(a)=="[object Array]"}function J(a,c){var b=/^\/\/[^\/]/,d=/^\w+\:\/\//;if(b.test(a)){a=location.protocol+a}else if(!d.test(a)){if(c!=null){c=(d.test(c))?c:J(c,c[0]=="/"?E:D);a=c+a}}return a}function t(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function P(a){var c=false;for(var b=0;b<a.scripts.length;b++){if(a.scripts[b].ready&&a.scripts[b].exec_trigger){c=true;a.scripts[b].exec_trigger();a.scripts[b].exec_trigger=null}}return c}function u(a,c,b,d){a.onload=a.onreadystatechange=function(){if((a.readyState&&a.readyState!="complete"&&a.readyState!="loaded")||c[b])return;a.onload=a.onreadystatechange=null;d()}}function K(a,c,b){b.ready=b.finished=true;for(var d=0;d<b.finished_listeners.length;d++){setTimeout(b.finished_listeners[d],0)}b.ready_listeners=[];b.finished_listeners=[]}function Q(d,e,f,i,g){setTimeout(function(){if("item"in h){if(!h[0]){setTimeout(arguments.callee,25);return}h=h[0]}var a=document.createElement("script"),c=e.real_src;if(e.type)a.type=e.type;if(e.charset)a.charset=e.charset;if(!f.preload&&!s){if(s)a.async=false;u(a,i,"finished",g);a.src=c;h.insertBefore(a,h.firstChild)}else if(G){i.elem=a;if(F){a.preload=true;a.onpreload=g}else{a.onreadystatechange=function(){if(a.readyState=="loaded")g();a.onreadystatechange=null}}a.src=c}else if(s){a.async=false;u(a,i,"finished",g);a.src=c;h.insertBefore(a,h.firstChild)}else if(c.indexOf(E)==0&&d[n]){var b=XMLHttpRequest?new XMLHttpRequest():(ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):null);b.onreadystatechange=function(){if(b.readyState==4){b.onreadystatechange=function(){};i.text=b.responseText+"\n//@ sourceURL="+c;g()}};b.open("GET",c);b.send()}else{a.type="text/cache-script";u(a,i,"ready",function(){h.removeChild(a);g()});a.src=c;h.insertBefore(a,h.firstChild)}},0)}function L(){var j={},R=!s&&(G||!O),o=[],q={},l;j[n]=!w;j[A]=false;j[v]=false;j[B]=false;j[C]="";function S(a,c,b,d){function e(){K(c,b,d);f=null}if(q[c.src].finished)return;if(!a[v])q[c.src].finished=true;var f=d.elem||document.createElement("script");if(c.type)f.type=c.type;if(c.charset)f.charset=c.charset;u(f,d,"finished",e);if(d.elem){d.elem=null}else if(d.text){f.onload=f.onreadystatechange=null;f.text=d.text}else{f.src=c.real_src}h.insertBefore(f,h.firstChild);if(d.text){e()}}function T(c,b,d){var e,f,i=function(){b.ready_cb(b,d,function(){S(c,b,d,e)})},g=function(){b.finished_cb(b,d)};b.src=J(b.src,c[C]);b.real_src=b.src+(c[B]?(/\?.*$/.test(b.src)?"&_":"?_")+~~(Math.random()*1E9)+"=":"");if(!q[b.src])q[b.src]={items:[],finished:false};f=q[b.src].items;if(c[v]||f.length==0){e=f[f.length]={ready:false,finished:false,ready_listeners:[i],finished_listeners:[g]};Q(c,b,d,e,(d.preload)?function(){e.ready=true;for(var a=0;a<e.ready_listeners.length;a++){setTimeout(e.ready_listeners[a],0)}e.ready_listeners=[]}:function(){K(b,d,e)})}else{e=f[0];if(e.finished){setTimeout(g,0)}else{e.finished_listeners.push(g)}}}function x(){var f,i=t(j,{}),g=[],m=0,y=false,k;function U(a,c,b){a.ready=true;a.exec_trigger=b;z()}function V(a,c){a.ready=a.finished=true;a.exec_trigger=null;for(var b=0;b<c.scripts.length;b++){if(!c.scripts[b].finished)return}c.finished=true;z()}function z(){while(m<g.length){if(H(g[m])){try{g[m]()}catch(err){}}else if(!g[m].finished){if(P(g[m]))continue;break}m++}if(m==g.length){y=false;k=false}}function M(){if(!k||!k.scripts){g.push(k={scripts:[],finished:true,preload:R&&y})}}f={script:function(){M();y=true;for(var e=0;e<arguments.length;e++){(function(a,c){if(!I(a)){c=[a]}for(var b=0;b<c.length;b++){M();a=c[b];if(H(a))a=a();if(!a)continue;if(I(a)){var d=[].slice.call(a);d.push(b,1);c.splice.call(c,d);b--;continue}if(typeof a=="string")a={src:a};a=t(a,{ready:false,ready_cb:U,finished:false,finished_cb:V});k.finished=false;k.scripts.push(a);T(i,a,k);if(i[A])f.wait()}})(arguments[e],arguments[e])}return f},wait:function(){if(arguments.length>0){for(var a=0;a<arguments.length;a++){g.push(arguments[a])}k=g[g.length-1]}else k=false;z();return f}};return{script:f.script,wait:f.wait,setOptions:function(a){t(a,i);i[n]=i[n]&&!w;return f}}}l={setGlobalDefaults:function(a){t(a,j);j[n]=j[n]&&!w;return l},setOptions:function(){return x().setOptions.apply(null,arguments)},script:function(){return x().script.apply(null,arguments)},wait:function(){return x().wait.apply(null,arguments)},queueScript:function(){o[o.length]={type:"script",args:[].slice.call(arguments)};return l},queueWait:function(){o[o.length]={type:"wait",args:[].slice.call(arguments)};return l},runQueue:function(){var a=l,c=o.length,b=c,d;for(;--b>=0;){d=o.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){p.$LAB=N;return l},sandbox:function(){return L()}};return l}p.$LAB=L();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);
View
5 next/LAB.min.js
@@ -0,0 +1,5 @@
+/*! LAB.js (LABjs :: Loading And Blocking JavaScript)
+ v2.0b (c) Kyle Simpson
+ MIT License
+*/
+(function(p){var N=p.$LAB,n="UseLocalXHR",A="AlwaysPreserveOrder",v="AllowDuplicates",B="CacheBust",C="BasePath",D=/^[^?#]*\//.exec(location.href)[0],E=/^\w+\:\/\/\/?[^\/]+/.exec(D)[0],h=document.head||document.getElementsByTagName("head"),w=!(XMLHttpRequest||ActiveXObject),O=(p.opera&&Object.prototype.toString.call(p.opera)=="[object Opera]")||("MozAppearance"in document.documentElement.style),r=document.createElement("script"),s=r.async===true,F=typeof r.preload=="boolean",G=F||(r.readyState&&r.readyState=="uninitialized");function H(a){return Object.prototype.toString.call(a)=="[object Function]"}function I(a){return Object.prototype.toString.call(a)=="[object Array]"}function J(a,c){var b=/^\/\/[^\/]/,d=/^\w+\:\/\//;if(b.test(a)){a=location.protocol+a}else if(!d.test(a)){if(c!=null){c=(d.test(c))?c:J(c,c[0]=="/"?E:D);a=c+a}}return a}function t(a,c){for(var b in a){if(a.hasOwnProperty(b)){c[b]=a[b]}}return c}function P(a){var c=false;for(var b=0;b<a.scripts.length;b++){if(a.scripts[b].ready&&a.scripts[b].exec_trigger){c=true;a.scripts[b].exec_trigger();a.scripts[b].exec_trigger=null}}return c}function u(a,c,b,d){a.onload=a.onreadystatechange=function(){if((a.readyState&&a.readyState!="complete"&&a.readyState!="loaded")||c[b])return;a.onload=a.onreadystatechange=null;d()}}function K(a,c,b){b.ready=b.finished=true;for(var d=0;d<b.finished_listeners.length;d++){setTimeout(b.finished_listeners[d],0)}b.ready_listeners=[];b.finished_listeners=[]}function Q(d,e,f,i,g){setTimeout(function(){if("item"in h){if(!h[0]){setTimeout(arguments.callee,25);return}h=h[0]}var a=document.createElement("script"),c=e.real_src;if(e.type)a.type=e.type;if(e.charset)a.charset=e.charset;if(!f.preload&&!s){if(s)a.async=false;u(a,i,"finished",g);a.src=c;h.insertBefore(a,h.firstChild)}else if(G){i.elem=a;if(F){a.preload=true;a.onpreload=g}else{a.onreadystatechange=function(){if(a.readyState=="loaded")g();a.onreadystatechange=null}}a.src=c}else if(s){a.async=false;u(a,i,"finished",g);a.src=c;h.insertBefore(a,h.firstChild)}else if(c.indexOf(E)==0&&d[n]){var b=XMLHttpRequest?new XMLHttpRequest():(ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):null);b.onreadystatechange=function(){if(b.readyState==4){b.onreadystatechange=function(){};i.text=b.responseText+"\n//@ sourceURL="+c;g()}};b.open("GET",c);b.send()}else{a.type="text/cache-script";u(a,i,"ready",function(){h.removeChild(a);g()});a.src=c;h.insertBefore(a,h.firstChild)}},0)}function L(){var j={},R=!s&&(G||!O),o=[],q={},l;j[n]=!w;j[A]=false;j[v]=false;j[B]=false;j[C]="";function S(a,c,b,d){function e(){K(c,b,d);f=null}if(q[c.src].finished)return;if(!a[v])q[c.src].finished=true;var f=d.elem||document.createElement("script");if(c.type)f.type=c.type;if(c.charset)f.charset=c.charset;u(f,d,"finished",e);if(d.elem){d.elem=null}else if(d.text){f.onload=f.onreadystatechange=null;f.text=d.text}else{f.src=c.real_src}h.insertBefore(f,h.firstChild);if(d.text){e()}}function T(c,b,d){var e,f,i=function(){b.ready_cb(b,d,function(){S(c,b,d,e)})},g=function(){b.finished_cb(b,d)};b.src=J(b.src,c[C]);b.real_src=b.src+(c[B]?(/\?.*$/.test(b.src)?"&_":"?_")+~~(Math.random()*1E9)+"=":"");if(!q[b.src])q[b.src]={items:[],finished:false};f=q[b.src].items;if(c[v]||f.length==0){e=f[f.length]={ready:false,finished:false,ready_listeners:[i],finished_listeners:[g]};Q(c,b,d,e,(d.preload)?function(){e.ready=true;for(var a=0;a<e.ready_listeners.length;a++){setTimeout(e.ready_listeners[a],0)}e.ready_listeners=[]}:function(){K(b,d,e)})}else{e=f[0];if(e.finished){setTimeout(g,0)}else{e.finished_listeners.push(g)}}}function x(){var f,i=t(j,{}),g=[],m=0,y=false,k;function U(a,c,b){a.ready=true;a.exec_trigger=b;z()}function V(a,c){a.ready=a.finished=true;a.exec_trigger=null;for(var b=0;b<c.scripts.length;b++){if(!c.scripts[b].finished)return}c.finished=true;z()}function z(){while(m<g.length){if(H(g[m])){try{g[m]()}catch(err){}}else if(!g[m].finished){if(P(g[m]))continue;break}m++}if(m==g.length){y=false;k=false}}function M(){if(!k||!k.scripts){g.push(k={scripts:[],finished:true,preload:R&&y})}}f={script:function(){M();y=true;for(var e=0;e<arguments.length;e++){(function(a,c){if(!I(a)){c=[a]}for(var b=0;b<c.length;b++){M();a=c[b];if(H(a))a=a();if(!a)continue;if(I(a)){var d=[].slice.call(a);d.push(b,1);c.splice.call(c,d);b--;continue}if(typeof a=="string")a={src:a};a=t(a,{ready:false,ready_cb:U,finished:false,finished_cb:V});k.finished=false;k.scripts.push(a);T(i,a,k);if(i[A])f.wait()}})(arguments[e],arguments[e])}return f},wait:function(){if(arguments.length>0){for(var a=0;a<arguments.length;a++){g.push(arguments[a])}k=g[g.length-1]}else k=false;z();return f}};return{script:f.script,wait:f.wait,setOptions:function(a){t(a,i);i[n]=i[n]&&!w;return f}}}l={setGlobalDefaults:function(a){t(a,j);j[n]=j[n]&&!w;return l},setOptions:function(){return x().setOptions.apply(null,arguments)},script:function(){return x().script.apply(null,arguments)},wait:function(){return x().wait.apply(null,arguments)},queueScript:function(){o[o.length]={type:"script",args:[].slice.call(arguments)};return l},queueWait:function(){o[o.length]={type:"wait",args:[].slice.call(arguments)};return l},runQueue:function(){var a=l,c=o.length,b=c,d;for(;--b>=0;){d=o.shift();a=a[d.type].apply(null,d.args)}return a},noConflict:function(){p.$LAB=N;return l},sandbox:function(){return L()}};return l}p.$LAB=L();(function(a,c,b){if(document.readyState==null&&document[a]){document.readyState="loading";document[a](c,b=function(){document.removeEventListener(c,b,false);document.readyState="complete"},false)}})("addEventListener","DOMContentLoaded")})(this);
View
2 next/LAB.src.js
@@ -1,5 +1,5 @@
/*! LAB.js (LABjs :: Loading And Blocking JavaScript)
- v2.0a (c) Kyle Simpson
+ v2.0b (c) Kyle Simpson
MIT License
*/

0 comments on commit 2fc75fe

Please sign in to comment.
Something went wrong with that request. Please try again.