Skip to content

Instantly share code, notes, and snippets.

@getify
Forked from ded/bench.html
Created May 24, 2011 05:32
Show Gist options
  • Save getify/e387c1d63656418db6aa to your computer and use it in GitHub Desktop.
Save getify/e387c1d63656418db6aa to your computer and use it in GitHub Desktop.
comparing LABjs and $script.js
<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>
<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>
@getify
Copy link
Author

getify commented May 24, 2011

Also, see this followup, which shows the comparison in a more powerful way:

https://gist.github.com/988188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment