Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0
Firefox 128
Mac OS X 10.15
Desktop
one year ago
getElementsByClassName
1.4M/s
querySelectorAll with .class
593/s
querySelectorAll with [attribute]
389/s
filter with getAttribute
170/s
filter with className
142/s
filter with classList
109/s
for with getAttribute
37/s
for with className
32/s
for with classList
29/s
View exact numbers
Test name Executions per second
getElementsByClassName 1,424,264 Ops/sec
querySelectorAll with .class 593 Ops/sec
querySelectorAll with [attribute] 389 Ops/sec
filter with getAttribute 170 Ops/sec
filter with className 142 Ops/sec
filter with classList 109 Ops/sec
for with getAttribute 37 Ops/sec
for with className 32 Ops/sec
for with classList 29 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: