Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Chrome 132
Mac OS X 10.15.7
Desktop
one year ago
getElementsByClassName
8.6M/s
querySelectorAll with .class
2K/s
querySelectorAll with [attribute]
2K/s
for with className
493/s
filter with className
402/s
for with getAttribute
331/s
filter with getAttribute
280/s
for with classList
235/s
filter with classList
197/s
View exact numbers
Test name Executions per second
getElementsByClassName 8,615,851 Ops/sec
querySelectorAll with .class 2,209 Ops/sec
querySelectorAll with [attribute] 1,740 Ops/sec
for with className 493 Ops/sec
filter with className 402 Ops/sec
for with getAttribute 331 Ops/sec
filter with getAttribute 280 Ops/sec
for with classList 235 Ops/sec
filter with classList 197 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: