Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Chrome 123
Windows
Desktop
2 years ago
getElementsByClassName
2.9M/s
querySelectorAll with .class
812/s
querySelectorAll with [attribute]
362/s
filter with className
181/s
filter with getAttribute
129/s
filter with classList
113/s
for with className
81/s
for with getAttribute
63/s
for with classList
57/s
View exact numbers
Test name Executions per second
getElementsByClassName 2,864,709 Ops/sec
querySelectorAll with .class 812 Ops/sec
querySelectorAll with [attribute] 362 Ops/sec
filter with className 181 Ops/sec
filter with getAttribute 129 Ops/sec
filter with classList 113 Ops/sec
for with className 81 Ops/sec
for with getAttribute 63 Ops/sec
for with classList 57 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: