The defining characteristic of LABjs is the ability to load *all* JavaScript files in parallel, as fast as the browser will allow, but giving you the option to ensure proper execution order if you have dependencies between files.*
.script("http://remote.tld/jquery.js").wait()
.script("/local/plugin1.jquery.js")
.script("/local/plugin2.jquery.js").wait()
.script("/local/init.js").wait(function(){
initMyPage();
});
The author indicates* that all four of these scripts will load in parallel (if the browsers allows). The wait() is to control execution order.
Require JS*
There are 5 basic ways to use require.js:
- Loading JavaScript files.
- Define a module that has other dependencies.
- Define an internationalization (i18n) bundle.
- Specify a text file dependency.
- Specify a JSONP service dependency.*
Use "order!" to execute in series:
require(["order!one.js", "order!two.js", "order!three.js"], function () {
//This callback is called after the three scripts finish loading.
});Comparison of LABjs & Require JS.
No comments:
Post a Comment