String building (v3)

Revision 3 of this benchmark created on


Preparation HTML

<div id="result">

</div>

Setup

var append_string = "abc";

Test runner

Ready to run.

Testing in
TestOps/sec
Direct DOM appending
var result = document.getElementById('result');
result.innerHTML = '';
for (var i = 0; i < 1000; i++) {
  result.innerHTML += append_string;
}
ready
Build and then add to DOM
var result = "";
for (var i = 0; i < 1000; i++) {
  result += append_string;
}
document.getElementById('result').innerHTML = result;
ready
the third way
var result = "";
for (var i = 0; i < 1000; i++) {
  result  = result + append_string;
}
document.getElementById('result').innerHTML = result;
ready

Revisions

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