innerHTML vs innerText vs nodeValue vs textContent (v19)

Revision 19 of this benchmark created on


Preparation HTML

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

Setup

var i = 0;

Test runner

Ready to run.

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

Revisions

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