jQuery append vs jQuery html vs native innerHTML vs native DOM (v84)

Revision 84 of this benchmark created on


Description

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

Preparation HTML

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

Setup

var len = 20;

Test runner

Ready to run.

Testing in
TestOps/sec
jquery .append()
for (var i = 0; i < len; i++) {
  $('#list').html( '<div>Test ' + i + '</div>' );
}
ready
native innerHTML
var list = document.getElementById('list');
for (var i = 0; i < len; i++) {
  list.innerHTML = '<div>Test ' + i + '</div>';
}
ready

Revisions

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