Search

8/04/2009

LABjs (Loading And Blocking JavaScript)

LABjs (Loading And Blocking JavaScript) - download
Ajaxian » LABjs: Simple abstraction for loading dependencies correctly
LABjs vs. Steve Souders' script loading methods


// That chain loads all 3 scripts in parallel, and then executes whatever code you want afterwards.
$LAB.script("script1.js").
script("script2.js").
script("script3.js").
block(function () {
// wait for all to load, then do something
script1Func();
script2Func();
script3Func();
});


// In this chain, 4 and 5 load in parallel, then 6 and 7 load in parallel, then functions from 4-7 get executed, then 8 loads by itself, then finally a function in 8 is called.
$LAB
.script("script4.js")
.script("script5.js")
.block()
.script("script6.js")
.script("script7.js")
.block(function(){
script4Func(); script5Func(); script6Func(); script7Func();
})
.script("script8.js")
.block(function(){
script8Func();
});

沒有留言: