Run details:
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
Windows
Desktop
one year ago
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
HTML Preparation code:
Script Preparation code:
Tests: