-
-
Save getify/e387c1d63656418db6aa to your computer and use it in GitHub Desktop.
comparing LABjs and $script.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="../vendor/lab2.min.js"></script> | |
<script type="text/javascript"> | |
var start = (+new Date); | |
$LAB.setGlobalDefaults({BasePath:"../vendor/"}); | |
// load a bunch of libraries (as separate $LAB chains so they each run ASAP) | |
$LAB.script('yui-utilities.js').wait(function(){YAHOO.util.Dom.get('yui').innerHTML = '✓';}); | |
$LAB.script('jquery.js').wait(function(){$('#jquery').html('✓'); | |
;}); | |
$LAB.script('mootools.js').wait(function(){document.id('mootools').innerHTML = '✓';}); | |
// this chain will wait for all the previously started loadings of the other chains | |
$LAB.script('yui-utilities.js','yui-utilities.js','mootools.js') | |
.wait(function() { | |
// benchmark time! | |
document.getElementById('total').innerHTML = (+new Date) - start; | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="../dist/script.js"></script> | |
<script type="text/javascript"> | |
var start = (+new Date); | |
// load a bunch of libraries | |
$script.path = '../vendor/'; | |
$script('yui-utilities.js','yui',function(){YAHOO.util.Dom.get('yui').innerHTML = '✓';}); | |
$script('jquery.js','jquery',function(){$('#jquery').html('✓'); | |
;}); | |
$script('mootools.js','moo',function(){document.id('mootools').innerHTML = '✓';}); | |
$script.ready(['yui','jquery','moo'],function() { | |
// benchmark time! | |
document.getElementById('total').innerHTML = (+new Date) - start; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, see this followup, which shows the comparison in a more powerful way:
https://gist.github.com/988188