Skip to content

Instantly share code, notes, and snippets.

@getify
Created May 24, 2011 05:53
Show Gist options
  • Save getify/988188 to your computer and use it in GitHub Desktop.
Save getify/988188 to your computer and use it in GitHub Desktop.
comparing LABjs and $script.js when parallel loading with execution order dependencies
<script src="../vendor/lab2.min.js"></script>
<script type="text/javascript">
var start = (+new Date);
// load some scripts dependent on each other (in parallel but preserving execution order)
$LAB
.setOptions({AlwaysPreserveOrder:true})
.script('a.js')
.script('b-needs-a.js')
.script('c-needs-b.js')
.wait(function(){
a() + b() + c();
// 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 some scripts dependent on each other (as nested $script calls, so NOT parallel)
$script('a.js',function(){
$script('b.js',function(){
$script('c.js',function(){
a() + b() + c();
// benchmark time!
document.getElementById('total').innerHTML = (+new Date) - start;
});
});
});
</script>
@getify
Copy link
Author

getify commented May 24, 2011

previous comparison with more identical syntax/scenario:

https://gist.github.com/e387c1d63656418db6aa

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