jQuery each2 plugin vs jQuery core .each method

Benchmark created by "Cowboy" Ben Alman on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<!-- the plugin -->
<script src="http://github.com/cowboy/jquery-misc/raw/master/jquery.ba-each2.js"></script>

<script>
  // Create a whole bunch of elements for iteration.
  var elems = $('<div/>').append(Array(1000).join('<span/>')).children();
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery each2 plugin
elems.each2(function(i, jq) {
 this; // DOM element
 jq; // jQuery object
});
ready
jQuery core .each method
elems.each(function(i, elem) {
 this; // DOM element
 $(this); // jQuery object
});
ready

Revisions

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