innerHTML vs innerText vs nodeValue vs textContent (v40)

Revision 40 of this benchmark created on


Preparation HTML

<div id="d"></div>
<span id="s"></span>
<script>
  var d = document.getElementById("d");
  var s = document.getElementById("s");
  var t = "abcd1234";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
innerText - div
d.innerText = t;
ready
innerText - span
s.innerText = t;
ready
innerHTML - div
d.innerHTML = t;
ready
innerHTML - span
s.innerHTML = t;
ready
childNodes[0].nodeValue - div
d.childNodes[0].nodeValue = t;
ready
childNodes[0].nodeValue - span
s.childNodes[0].nodeValue = t;
ready
firstChild.nodeValue - div
d.firstChild.nodeValue = t;
ready
firstChild.nodeValue - span
s.firstChild.nodeValue = t
ready
textContent - div
d.textContent = t;
ready
textContent - span
s.textContent = t;
ready

Revisions

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