jQuery append vs html vs innerHTML list performance (v45)

Revision 45 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="divHeader">
</div>

Setup

var len = 20;

Test runner

Ready to run.

Testing in
TestOps/sec
jquery .append()
$(function() {
    $("#divHeader").append(
      "<div id='divLogo'>" +
      "<img src='images/logo.jpg' alt='B.K.K.(1985) PUBLIC COMPANY LIMITED' />" +
      "</div>" +
      "<div id='divLanguage'>" +
      "<p class='language'>" +
      "<a href='index_th.html'>ไทย | </a><a href='index.html'>Eng</a>" +
      "</p>" +
      "</div>" +
      "<hr id='hrDropdownBar' />"
    )
ready
jQuery .html()
$(function() {
    $("#divHeader").html(
      '<div id="divLogo">' +
      '<img src="images/logo.jpg" alt="B.K.K.(1985) PUBLIC COMPANY LIMITED" />' +
      '</div>' +
      '<div id="divLanguage">' +
      '<p class="language">' +
      '<a href="index_th.html">ไทย | </a><a href="index.html">Eng</a>' +
      '</p>' +
      '</div>' +
      '<hr id="hrDropdownBar" />'
    )
ready
javascript innerHTML
// async test
var html = '';
for (var i = 0; i < len; i++) {
  html += '<div>Test ' + i + '</div>';
}

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.