jQuery vs Underscore Each

JavaScript performance comparison

Revision 3 of this test case created

Info

Is jQuery's $.each or Underscore's _.each faster?

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="//documentcloud.github.com/underscore/underscore-min.js">
</script>
<script src="//www.modernizr.com/downloads/modernizr-2.0.js">
</script>
<div id="content">
</div>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jQuery Each
var $content = $('#content');
$(Modernizr).each(function(property, value) {
  $('<div/>', {
    id: property,
    css: {
      width: '100%'
    },
    html: property + ' ' + value
  }).appendTo($content);
});
pending…
Underscore.js Each
var $content = $('#content');
_(Modernizr).each(function(value, property) {
  $('<div/>', {
    id: property,
    css: {
      width: '100%'
    },
    html: property + ' ' + value
  }).appendTo($content);
});
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment