Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
childNodes vs children vs firstChild/nextSibling vs firstElementChild/nextElementSibling
Fastest way to list children
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15
Browser:
Safari 17
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
childNodes
5826913.0 Ops/sec
children
3683868.2 Ops/sec
firstChild nextSibling
21687030.0 Ops/sec
firstElementChild nextElementChild
21852740.0 Ops/sec
ChildNodes2
7506121.0 Ops/sec
HTML Preparation code:
<html> <body> <div id='test'> <div name='a'></div> <div name='b'></div> <div name='c'></div> </div> </body> </html>
Script Preparation code:
var parent = document.getElementById('test');
Tests:
childNodes
parent.childNodes.forEach(function (node) { let n = node; });
children
for (let i = 0; i < parent.children.length; i++) { let n = parent.children[i]; }
firstChild nextSibling
let elem = parent.firstChild; do { let n = elem; } while (elem = elem.nextSibling)
firstElementChild nextElementChild
let elem = parent.firstElementChild; do { let n = elem; } while (elem = elem.nextElementSibling)
ChildNodes2
let children = parent.childNodes; for (let i = 0; i < children.length; i++) { let n = children[i]; }