Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
getElementById, querySelector, querySelectorAll and with if
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Browser:
Chrome 124
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
getElementById
9.2M/s
with iF
9.1M/s
querySelector
5.7M/s
querySelectorAll
2.8M/s
View exact numbers
Test name
Executions per second
✓
getElementById
9,159,575 Ops/sec
with iF
9,110,585 Ops/sec
querySelector
5,668,855 Ops/sec
querySelectorAll
2,801,472 Ops/sec
HTML Preparation code:
<div id="test">Test</div>
Tests:
getElementById
document.getElementById("test");
querySelector
document.querySelector("#test")
querySelectorAll
document.querySelectorAll("#test")
with iF
var sel = '#test'; if (sel[0] === '#') { document.getElementById("test"); } else { document.querySelectorAll("#test") }