Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Chrome 129
Mac OS X 10.15.7
Desktop
one year ago
getElementsByClassName
3.2M/s
querySelectorAll with [attribute]
1K/s
querySelectorAll with .class
1K/s
filter with className
276/s
filter with getAttribute
195/s
filter with classList
137/s
for with className
78/s
for with getAttribute
78/s
for with classList
72/s
View exact numbers
Test name Executions per second
getElementsByClassName 3,234,846 Ops/sec
querySelectorAll with [attribute] 1,137 Ops/sec
querySelectorAll with .class 1,115 Ops/sec
filter with className 276 Ops/sec
filter with getAttribute 195 Ops/sec
filter with classList 137 Ops/sec
for with className 78 Ops/sec
for with getAttribute 78 Ops/sec
for with classList 72 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: