Read via innerHTML, nodeValue and textContent
JavaScript performance comparison
Info
rev.7 + nodeValue2
Preparation code
<div id="div">1,2,3,4</div>
<span id="span">1,2,3,4</span>
<ul>
<li id="li">1,2,3,4</li>
</ul>
<script>
var a = document.getElementById('div'),
b = document.getElementById('span'),
e = document.getElementById('li'),
c = a.firstChild,
d = b.firstChild,
f = e.firstChild,
s;
</script>
Preparation code output
1,2,3,4
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.
| Test | Ops/sec | |
|---|---|---|
textContent - div |
|
pending… |
textContent - li |
|
pending… |
innerHTML - div |
|
pending… |
innerHTML - li |
|
pending… |
nodeValue - div |
|
pending… |
nodeValue - li |
|
pending… |
nodeValue2 - div |
|
pending… |
nodeValue2 - li |
|
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:
- Revision 1: published by Rob
- Revision 2: published by Rob
- Revision 3: published by Rob
- Revision 5: published
- Revision 6: published
- Revision 7: published by CoolCmd
- Revision 8: published by CoolCmd
- Revision 9: published by Allan
- Revision 10: published by pikappa
0 comments