.append VS .html VS .innerHTML performance

All three are slow to me. Modifying the dom on each iteration is slow.

http://jsperf.com/jquery-append-vs-html-list-performance/24

I just added a new test in there:

var html = [];
for (var i = 0; i < len; i++) {
  html.push('<div>Test ' + i + '</div>');
}

document.getElementById('list').innerHTML = html.join('');

This is much faster again. 🙂

My method in Firefox does 26k Ops/sec vs 1,000, 10,000, and 13

enter image description here

Leave a Comment