innerHTML vs innerText vs nodeValue vs textContent

JavaScript performance comparison

Revision 48 of this test case created by Peter

Preparation code

<div id="divinputme"></div>
<script>
var a = document.getElementById('divinputme');
</script>
      
<script>
Benchmark.prototype.setup = function() {
  a.innerHTML = '<ul><li></li><li></li><li></li><li></li></ul>';

};
</script>

Preparation code output

<div id="divinputme"></div>

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 = '';
pending…
innerHTML - div
a.innerHTML = '';
pending…
textContent - div
a.textContent = '';
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