innerHTML vs innerText vs nodeValue vs textContent (v18)

Revision 18 of this benchmark created on


Preparation HTML

<div id="divinputme">
</div>
<span id="spaninputme">
</span>
<script>
  var a = document.getElementById('divinputme'),
      b = document.getElementById('spaninputme');
</script>

Test runner

Ready to run.

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

Revisions

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