innerHTML vs innerText vs nodeValue (v28)

Revision 28 of this benchmark created by Ojle Nenpleto on


Preparation HTML

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

Setup

document.getElementById('divinputme').innerHTML = '';
  document.getElementById('spaninputme').innerHTML = '';

Teardown



            document.getElementById('divinputme').innerHTML = '';
  document.getElementById('spaninputme').innerHTML = '';
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
innerText - div
a.innerText = s;
ready
innerHTML - div
a.innerHTML = s;
ready
nodeValue - div
a.nodeValue = s;
ready
textnode - div
a.appendChild(document.createTextNode(s))
ready

Revisions

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