jQuery vs createElement

JavaScript performance comparison

Revision 84 of this test case created by mmm

Info

Benchmarks from answer on StackOverflow: http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent/268520

Preparation code

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

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
$()
var idWrap = $('<div id="id"><div id="a"><div id="b"><div id="c"><div id="d"><div id="e"></div></div></div></div></div>');

$(idWrap).find('#a').width(100).find('#b').width(100).find('#c').width(100).find('#d').width(100).find('#e').width(100);

$(idWrap).appendTo('body');
pending…
document.createElement
var id=document.createElement('div');
id.id='id';

var a=document.createElement('div');
a.id='a';

var b=document.createElement('div');
b.id='b';

var c=document.createElement('div');
c.id='c';

var d=document.createElement('div');
d.id='d';

var e=document.createElement('div');
e.id='e';

$(id).append($(a)).find('#a').append($(b)).width(100).find('#b').append($(c)).width(100).find('#c').append($(d)).width(100).find('#d').append($(e)).width(100).find('#e').width(100);

$(id).appendTo('body');
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