jQuery vs Underscore Each

JavaScript performance comparison

Test case created by James Brown

Preparation code

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

<div id="content"></div>
    

Preparation code output

<script src="https://documentcloud.github.com/underscore/underscore-min.js"></script> <script src="https://www.modernizr.com/downloads/modernizr-2.0.js"></script> <div id="content"></div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
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,object){
	$('<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.

0 Comments