Read via innerHTML, nodeValue and textContent

JavaScript performance comparison

Revision 8 of this test case created by CoolCmd

Info

rev.7 + nodeValue2

Preparation code

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

Preparation code output

1,2,3,4
1,2,3,4

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
textContent - div
s = a.textContent;
pending…
textContent - span
s = b.textContent;
pending…
innerHTML - div
s = a.innerHTML;
pending…
innerHTML - span
s = b.innerHTML;
pending…
nodeValue - div
s = a.firstChild.nodeValue;
pending…
nodeValue - span
s = b.firstChild.nodeValue;
pending…
nodeValue2 - div
s = c.nodeValue;
pending…
nodeValue2 - span
s = d.nodeValue;
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment