HTML Preparation code:
Script Preparation code:
Tests:

Historical Performance Data aggregated from 14 community runs

Desktop Results:
Chrome 14 runs
getElementsByClassName
2.6M/s
querySelectorAll with .class
549/s
querySelectorAll with [attribute]
318/s
filter with className
128/s
filter with getAttribute
89/s
for with className
80/s
filter with classList
67/s
for with classList
62/s
for with getAttribute
61/s

Fastest: getElementsByClassName (42144.7x faster)

View exact numbers
  • getElementsByClassName: 2,562,338 ops/sec
  • querySelectorAll with .class: 549 ops/sec
  • querySelectorAll with [attribute]: 318 ops/sec
  • filter with className: 128 ops/sec
  • filter with getAttribute: 89 ops/sec
  • for with className: 80 ops/sec
  • filter with classList: 67 ops/sec
  • for with classList: 62 ops/sec
  • for with getAttribute: 61 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
    querySelectorAll with .class
    querySelectorAll with [attribute]
    filter with classList
    filter with className
    filter with getAttribute
    for with classList
    for with className
    for with getAttribute
    getElementsByClassName

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Chrome 137 on Windows
View result in a separate tab
getElementsByClassName
2.7M/s
querySelectorAll with .class
496/s
querySelectorAll with [attribute]
353/s
for with className
136/s
filter with className
125/s
for with getAttribute
95/s
filter with getAttribute
91/s
filter with classList
70/s
for with classList
69/s
View exact numbers
Test name Executions per second
getElementsByClassName 2,704,543 Ops/sec
querySelectorAll with .class 496 Ops/sec
querySelectorAll with [attribute] 353 Ops/sec
for with className 136 Ops/sec
filter with className 125 Ops/sec
for with getAttribute 95 Ops/sec
filter with getAttribute 91 Ops/sec
filter with classList 70 Ops/sec
for with classList 69 Ops/sec