Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Chrome 129
Windows
Desktop
one year ago
getElementsByClassName
1.3M/s
querySelectorAll with .class
386/s
querySelectorAll with [attribute]
366/s
filter with className
114/s
filter with getAttribute
76/s
filter with classList
48/s
for with className
42/s
for with getAttribute
34/s
for with classList
28/s
View exact numbers
Test name Executions per second
getElementsByClassName 1,254,362 Ops/sec
querySelectorAll with .class 386 Ops/sec
querySelectorAll with [attribute] 366 Ops/sec
filter with className 114 Ops/sec
filter with getAttribute 76 Ops/sec
filter with classList 48 Ops/sec
for with className 42 Ops/sec
for with getAttribute 34 Ops/sec
for with classList 28 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: