Work with DOM (String vs temp HTML element))

JavaScript performance comparison

Test case created by underfind

Preparation code

<div id="container1">
<div id="container2">
 
<script>
Benchmark.prototype.setup = function() {
    var cntr1 = document.getElementById('container1');
    var cntr2 = document.getElementById('container2');
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
createElement
var temp1 = document.createElement('div');

for (var j = 0; j < 100; j++) {
  temp1.innerHTML += "<div>1</div>";
}
pending…
string as buffer
var temp2 = "<div>";

for (var l = 0; l < 100; l++) {
  temp2 += "<div>1</div>";
}

temp2 += "</div>";
pending…

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

Compare results of other browsers

0 comments

Add a comment