jQuery append vs html vs innerHTML list performance (v123)

Revision 123 of this benchmark created by C E on


Description

Just a simple example showing the speed difference between populating a list with .append() & .html() and innerHTML

Preparation HTML

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

Setup

var html = '';
    
    for (var i = 0; i < 20; i++) {
      html += '<div>Test ' + i + '</div>';
    }

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery .append()
$('#list').append(html);
ready
jQuery .html()
$('#list').html(html);
ready
javascript innerHTML
document.getElementById('list').innerHTML = html;
ready

Revisions

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