jQuery append vs html vs innerHTML list performance II

JavaScript performance comparison

Revision 113 of this test case created by Kanitta

Preparation code

<script src="https://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

<h1>List 1</h1> <div id="list1"></div> <h1>List 2</h1> <div id="list2"></div> <h1>List 3</h1> <div id="list3"></div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
javascript innerHTML
var html = '';
for (var i = 0; i < len; i++) {
  html += '<div>Test ' + i + '</div>';
}

document.getElementById('list3').innerHTML = html;
pending…
jQuery .html()
var html = '';
for (var i = 0; i < len; i++) {
  html += '<div>Test ' + i + '</div>';
}

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

0 Comments

List 1

List 2

List 3