innerHTML vs innerText vs nodeValue

JavaScript performance comparison

Revision 50 of this test case created by Andrew

Preparation code

<div id="divinputme">test</div>
<span id="spaninputme">test</span>
<script>
  var a = document.getElementById('divinputme'),
      b = document.getElementById('spaninputme');
  s = '1,2,3,4';
</script>
    

Preparation code output

<div id="divinputme">test</div> <span id="spaninputme">test</span>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
innerText - div
a.innerText = s;
pending…
innerText - span
b.innerText = s;
pending…
innerHTML - div
a.innerHTML = s;
pending…
innerHTML - span
b.innerHTML = s;
pending…
nodeValue - div
a.childNodes[0].nodeValue = s;
pending…
nodeValue - span
b.childNodes[0].nodeValue = s;
pending…

Compare results of other browsers

Revisions

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

0 Comments

test
test