querySelector by attribute (partial matching) vs querySelector by attribute (partial matching) - variant (starts with) vs getElementById vs getElementsByTagNameFastest: getElementById (2.3x faster)
7,784,466 ops/sec
5,070,289 ops/sec
3,413,242 ops/sec
3,352,945 ops/sec
Fastest: getElementById (5.6x faster)
23,445,652 ops/sec
11,260,888 ops/sec
4,173,306 ops/sec
4,153,218 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| querySelector by attribute (partial matching) | |
| querySelector by attribute (partial matching) - variant (starts with) | |
| getElementById | |
| getElementsByTagName |
| Test name | Executions per second |
|---|---|
| ✓ getElementById | 25,627,976 Ops/sec |
| getElementsByTagName | 9,649,841 Ops/sec |
| querySelector by attribute (partial matching) - variant (starts with) | 3,739,892 Ops/sec |
| querySelector by attribute (partial matching) | 3,199,106 Ops/sec |