nextSibling vs childNodes
JavaScript performance comparison
Info
Test the relative performance of iterating through child nodes using nextSibling vs iterating through the childNodes array.
Preparation code
<div id="container">
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
<p>Child</p>
</div>
<script>
var container = document.getElementById('container');
function process(element) {}
</script>
Preparation code output
Child
Child
Child
Child
Child
Child
Child
Child
Child
Child
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
childNodes |
|
pending… |
childNodes, cached |
|
pending… |
nextSibling |
|
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 Adrian Sutton
- Revision 2: published
- Revision 3: published
- Revision 4: published by TimTucker
- Revision 5: published by Nick
- Revision 7: published
- Revision 8: published by Sam3000
- Revision 9: published by Sam3000
- Revision 10: published
- Revision 11: published
- Revision 12: published
- Revision 13: published
0 comments