innerHTML vs innerText vs nodeValue vs textContent (v17)

Revision 17 of this benchmark created by NAIF 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 = 'div-innerText';
ready
innerText - span
b.innerText = 'span-innerText';
ready
innerHTML - div
a.innerHTML = 'div-innerHTML';
ready
innerHTML - span
b.innerHTML = 'span-innerHTML';
ready
nodeValue - div
a.firstChild.nodeValue = 'div-nodeValue';
ready
nodeValue - span
b.firstChild.nodeValue = 'span-nodeValue';
ready
textContent - div
a.textContent = 'div-textContent';
ready
textContent - span
b.textContent = 'span-textContent';
ready

Revisions

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