Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Chrome 128
Windows
Desktop
one year ago
getElementsByClassName
1.1M/s
querySelectorAll with .class
332/s
querySelectorAll with [attribute]
262/s
filter with className
97/s
filter with getAttribute
72/s
filter with classList
49/s
for with className
29/s
for with getAttribute
28/s
for with classList
23/s
View exact numbers
Test name Executions per second
getElementsByClassName 1,093,876 Ops/sec
querySelectorAll with .class 332 Ops/sec
querySelectorAll with [attribute] 262 Ops/sec
filter with className 97 Ops/sec
filter with getAttribute 72 Ops/sec
filter with classList 49 Ops/sec
for with className 29 Ops/sec
for with getAttribute 28 Ops/sec
for with classList 23 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: