Append object: jQuery vs native

JavaScript performance comparison

Test case created by Chen-Pang He

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<ul id="test-list">
</ul>
<script>
Benchmark.prototype.setup = function() {
    var testList = document.getElementById("test-list");
    var $testList = $(testList);
};

Benchmark.prototype.teardown = function() {
    $testList.empty();
};
</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
Append string
$testList.append("<li>Hello world!</li>");
pending…
Append DOM
var li = document.createElement("li");
li.appendChild(document.createTextNode("Hello world!"));
$testList.append(li);
pending…
Native
var li = document.createElement("li");
li.appendChild(document.createTextNode("Hello world!"));
testList.appendChild(li);
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment