innerHTML vs innerText vs nodeValue vs textContent (v20)

Revision 20 of this benchmark created on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
innerText - div
var test = a.innerText;
ready
innerText - span
var test = b.innerText;
ready
innerHTML - div
var test = a.innerHTML;
ready
innerHTML - span
var test = b.innerHTML;
ready
nodeValue - div
var test = a.firstChild.nodeValue;
ready
nodeValue - span
var test = b.firstChild.nodeValue;
ready
textContent - div
var test = a.textContent;
ready
textContent - span
var test = b.textContent;
ready

Revisions

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