jQuery elementBuilder vs. cloneNode

JavaScript performance comparison

Revision 3 of this test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var body = document.body;
};
</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
jQuery
var trEl = $('<table><tr><td style="height:0px;width:60px"></td><td style="height:0px;width:2px;"></td><td style="height:0px;width:18px;"></td></tr></table>');

$(body[0]).append(trEl);
 
pending…
regular JS
var t = document.createDocumentFragment();
var ta = document.createElement('table');
var tr = document.createElement('tr');
var td = document.createElement('td');

tr.appendChild(td.cloneNode());
tr.appendChild(td.cloneNode());
tr.appendChild(td.cloneNode());
ta.appendChild(tr);
var tabl = t.appendChild(ta);

body.appendChild(t);

 
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