jQuery each vs each2 vs quickeach vs
JavaScript performance comparison
Preparation code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://rawgit.com/cowboy/jquery-misc/master/jquery.ba-each2.js"></script>
<script>
//quickEach
(function($) {
$.fn.quickEach = function(f) {
var j = $([0]),
i = -1,
l = this.length,
c;
while (++i < l && (c = j[0] = this[i]) && f.call(j, i, c) !== false);
return this;
};
})(jQuery);
// Create a whole bunch of elements for iteration.
var elems = $('<div/>').append(Array(1000).join('<span/>')).children();
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
jQuery core
.each method
|
|
pending… |
jQuery each2 plugin
|
|
pending… |
raw for-loop... with $()[..] replacement
|
|
pending… |
jQuery quickEach plugin
|
|
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.
- Revision 1: published "Cowboy" Ben Alman
- Revision 2: published "Cowboy" Ben Alman
- Revision 3: published
- Revision 4: published David
- Revision 5: published David
- Revision 6: published Kyle Simpson and last updated
- Revision 7: published Flatlineato
- Revision 13: published Scott Rycroft
- Revision 15: published Scott Rycroft
- Revision 16: published Jason DiMeo
- Revision 18: published Jason DiMeo
- Revision 22: published creage
- Revision 23: published
- Revision 24: published
- Revision 25: published
- Revision 27: published
- Revision 28: published Grant
- Revision 31: published
- Revision 32: published Yukulélé
- Revision 34: published
- Revision 35: published jquery-instanceof-vs-jquery
- Revision 36: published Doug Gale
- Revision 37: published
- Revision 38: published
- Revision 39: published creage
- Revision 41: published
- Revision 42: published
- Revision 43: published
- Revision 44: published
- Revision 45: published KergeKacsa at Index.hu
- Revision 47: published a
0 Comments