jQuery vs Underscore Each (v3)

Revision 3 of this benchmark created on


Description

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

Preparation HTML

<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>

Test runner

Ready to run.

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

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.