Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
getElementById vs querySelector2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0
Browser:
Firefox 122
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
getElementById
9.2M/s
querySelector
4.3M/s
View exact numbers
Test name
Executions per second
✓
getElementById
9,237,728 Ops/sec
querySelector
4,322,403 Ops/sec
HTML Preparation code:
<div id="testElement2">You can't do it with the strike tag OR the text-decoration:line-through style. The line position is built-in. You could roll your own style for that, but it would be a huge PITA.</div> <div id="testElement12"></div> <div id="testElement"></div> <div> <div id="testElement4"><button></button></div> <div id="testElement5"></div> </div> <div id="testElement6"></div> <div id="testElement7">You can't do it with the strike tag OR the text-decoration:line-through style. The line position is built-in. You could roll your own style for that, but it would be a huge PITA.</div> <div id="testElement8"></div> <div id="testElement9"></div>
Tests:
getElementById
var el = document.getElementById('testElement'); var className = el.className;
querySelector
var el = document.querySelector('#testElement'); var className = el.className;