HTML Preparation code:
Tests:

Historical Performance Data aggregated from 14 community runs

Desktop Results:
Firefox 8 runs
getElementById
7.8M/s
getElementsByTagName
5.1M/s
querySelector by attribute (partial matching) - variant (starts with)
3.4M/s
querySelector by attribute (partial matching)
3.4M/s

Fastest: getElementById (2.3x faster)

View exact numbers
  • getElementById: 7,784,466 ops/sec
  • getElementsByTagName: 5,070,289 ops/sec
  • querySelector by attribute (partial matching) - variant (starts with): 3,413,242 ops/sec
  • querySelector by attribute (partial matching): 3,352,945 ops/sec
Chrome 6 runs
getElementById
23.4M/s
getElementsByTagName
11.3M/s
querySelector by attribute (partial matching) - variant (starts with)
4.2M/s
querySelector by attribute (partial matching)
4.2M/s

Fastest: getElementById (5.6x faster)

View exact numbers
  • getElementById: 23,445,652 ops/sec
  • getElementsByTagName: 11,260,888 ops/sec
  • querySelector by attribute (partial matching) - variant (starts with): 4,173,306 ops/sec
  • querySelector by attribute (partial matching): 4,153,218 ops/sec

Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    querySelector by attribute (partial matching)
    querySelector by attribute (partial matching) - variant (starts with)
    getElementById
    getElementsByTagName

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Chrome 149 on Windows
View result in a separate tab
getElementById
25.6M/s
getElementsByTagName
9.6M/s
querySelector by attribute (partial matching) - variant (starts with)
3.7M/s
querySelector by attribute (partial matching)
3.2M/s
View exact numbers
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