Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
parentNode vs firstChild vs nextSibling vs previousSibling (plus bonus: firstChild.nextSibling, querySelectorAll)
Fastest way to find nodes
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
parentNode
30653476.0 Ops/sec
firstChild
29747742.0 Ops/sec
nextSibling
29740668.0 Ops/sec
previousSibling
29785298.0 Ops/sec
firstChild.nextSibling
27951970.0 Ops/sec
querySelectorAll
6172009.0 Ops/sec
HTML Preparation code:
<html> <body> <div id='test'><div class='child'></div><div></div><div></div></div> </body> </html>
Script Preparation code:
var parent = document.getElementById('test'); var child1 = parent.children[0] var child2 = parent.children[1]
Tests:
parentNode
let n = child1.parentNode;
firstChild
let n = parent.firstChild;
nextSibling
let n = child1.nextSibling
previousSibling
let n = child2.previousSibling
firstChild.nextSibling
let n = parent.firstChild.nextSibling
querySelectorAll
let n = parent.querySelectorAll(".child")[0]