Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133
Mac OS X 10.15.7
Desktop
one year ago
getElementsByClassName
9.6M/s
querySelectorAll with .class
3K/s
querySelectorAll with [attribute]
3K/s
for with className
491/s
filter with className
398/s
for with getAttribute
368/s
filter with getAttribute
312/s
filter with classList
166/s
for with classList
117/s
View exact numbers
Test name Executions per second
getElementsByClassName 9,612,084 Ops/sec
querySelectorAll with .class 2,786 Ops/sec
querySelectorAll with [attribute] 2,635 Ops/sec
for with className 491 Ops/sec
filter with className 398 Ops/sec
for with getAttribute 368 Ops/sec
filter with getAttribute 312 Ops/sec
filter with classList 166 Ops/sec
for with classList 117 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: