jQuery append vs html vs innerHTML list performance II

JavaScript performance comparison

Revision 113 of this test case created by Kanitta

Info

jQuery append vs html vs innerHTML list performance II

Preparation code

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

<h1>List 1</h1>
<div id="list1"></div>
<h1>List 2</h1>
<div id="list2"></div>
<h1>List 3</h1>
<div id="list3"></div>
<script>
Benchmark.prototype.setup = function() {
    var len = 100;
};
</script>

Preparation code output

List 1

List 2

List 3

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 .append()
for (var i = 0; i < len; i++) {
  $('#list1').append('<div>Test ' + i + '</div>');
}
pending…
jQuery .html()
var html = '';
for (var i = 0; i < len; i++) {
  html += '<div>Test ' + i + '</div>';
}

$('#list2').html(html);
pending…
javascript innerHTML
var html = '';
for (var i = 0; i < len; i++) {
  html += '<div>Test ' + i + '</div>';
}

document.getElementById('list3').innerHTML = html;
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