innerHTML vs innerText vs nodeValue vs textContent

JavaScript performance comparison

Revision 49 of this test case created by

Preparation code

<div id="content">hello world</div>
      
<script>
Benchmark.prototype.setup = function() {
  var el = document.getElementById('content');
  var s;

};
</script>

Preparation code output

<div id="content">hello world</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
s = el.innerText;
pending…
innerHTML - div
s = el.innerHTML;
pending…
textContent - div
s = el.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

hello world