jQuery Sizzle vs Create Element

JavaScript performance comparison

Revision 2 of this test case created by Toxigenicpoem

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="result" style="display:none;">
</div>

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
using sizzle
var myStringArray = ['apple', 'banana', 'melon'];

var $ul = $(document.createElement('ul'));


for (var i = 0; i < myStringArray.length; i++) {
$li = $(document.createElement('li'),{'text': myStringArray[i]});
$ul[0].appendChild($li[0]);
}

var result = document.getElementById('result');
result.appendChild($ul[0]);
pending…
using document.createElement
var ul = document.createElement('ul');
var myStringArray = ['apple', 'banana', 'melon'];
for (var i = 0; i < myStringArray.length; i++) {
  var li = document.createElement('li');
  li.innerText = myStringArray[i];
  ul.appendChild(li);
}
var result = document.getElementById('result');
result.appendChild(ul);
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