Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0
Chrome 121
Windows
Desktop
2 years ago
getElementsByClassName
2.6M/s
querySelectorAll with .class
3K/s
querySelectorAll with [attribute]
268/s
filter with className
258/s
filter with classList
121/s
filter with getAttribute
116/s
for with className
90/s
for with classList
67/s
for with getAttribute
59/s
View exact numbers
Test name Executions per second
getElementsByClassName 2,564,466 Ops/sec
querySelectorAll with .class 2,754 Ops/sec
querySelectorAll with [attribute] 268 Ops/sec
filter with className 258 Ops/sec
filter with classList 121 Ops/sec
filter with getAttribute 116 Ops/sec
for with className 90 Ops/sec
for with classList 67 Ops/sec
for with getAttribute 59 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: