Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131
Mac OS X 10.15.7
Desktop
one year ago
Benchmark.js
getElementById
21.6M/s
getElementsByTagName
11.1M/s
querySelector by attribute (partial matching) - variant (starts with)
2.7M/s
querySelector by attribute (partial matching)
2.7M/s
View exact numbers
Test name Executions per second
getElementById 21,583,268 Ops/sec
getElementsByTagName 11,061,958 Ops/sec
querySelector by attribute (partial matching) - variant (starts with) 2,714,571 Ops/sec
querySelector by attribute (partial matching) 2,666,290 Ops/sec
HTML Preparation code:
Tests: