jQuery vs createElement

JavaScript performance comparison

Revision 147 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js">
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
document.createElement
var outerWrapper = document.createElement('div');
outerWrapper.className = "img-wrapper-outer";

var innerWrapper = document.createElement('div');
innerWrapper.className = "img-wrapper-inner";

var image = new Image();
image.src = "asdfghj"
image.style.visibility = "hidden";

innerWrapper.appendChild(image);
outerWrapper.appendChild(innerWrapper);
pending…
jQuery
var $outerWrapper = $('<div class="img-wrapper-outer" />');

var $innerWrapper = $('<div class="img-wrapper-inner" />');

var $image = $('img').prop('src', "asdfghj").css('visibility', 'hidden');

$innerWrapper.append($image);
$outerWrapper.append($innerWrapper);
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