jQuery append vs html vs innerHTML list performance (v111)

Revision 111 of this benchmark created on


Preparation HTML

<script src="https://code.jquery.com/jquery-1.9.1.min.js">
</script>
<select id="list" ></select>

Setup

var len = 20;
  var html=[];
  for (var i = 0; i < len; i++) {
    html.push('<option value="'+ i +'">Test' + i + '</option>');
  
  }
  
  var htmlArrayObjects =[];
  for (var i = 0; i < len; i++) {
    html.push({label:'Test' + i,value:i}
  );
  
  }
  
  
  var htmlOption = '';
  for (var a = 0; a < len; a++) {
    htmlOption = htmlOption + '<option value="'+ a +'">Test' + a + '</option>';
  
  }

Test runner

Ready to run.

Testing in
TestOps/sec
jquery .append()
  $('#list').append(html.join(''));
ready
Manually new Options
for(i = 0; i < htmlArrayObjects.length; i++){
document.getElementById("list").options[i] = new Option(htmlArrayObjects.label,htmlArrayObjects.value);
                     }
ready
jQuery .html()
  $('#list').html(htmlOption );
ready
javascript innerHTML
 $('#list').append(htmlOption );
ready
Concat
 $('#list').html(html.join(''));
ready

Revisions

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