Work with DOM (String vs temp HTML element))

JavaScript performance comparison

Test case created by underfind

Preparation code

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

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
var temp1 = document.createElement('div');

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

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

temp2 += "</div>";

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

Compare results of other browsers


Comment form temporarily disabled.

Add a comment