text content

Benchmark created by galambalazs on


Description

Observation: .textContent ||.innerText order does matter in modern browsers. IE doesn't care, so put textContent first always.

Preparation HTML

<div id="text">content to be retrieved</div>
<script>
  var elem = document.getElementById("text");
  var node = elem.firstChild;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
var x = elem.innerHTML;
ready
textContent || innerText
var x = elem.textContent || elem.innerText;
ready
innerText || textContent
var x = elem.innerText || elem.textContent;
ready
data
var x = node.data;
ready
nodeValue
var x = node.nodeValue;
ready

Revisions

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

  • Revision 1: published by galambalazs on
  • Revision 2: published by galambalazs on
  • Revision 3: published by galambalazs on
  • Revision 9: published by aeosynth on
  • Revision 10: published by Mayhem on
  • Revision 11: published on