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
658/s
filter with className
245/s
filter with getAttribute
134/s
filter with classList
126/s
querySelectorAll with [attribute]
122/s
for with className
88/s
for with classList
67/s
for with getAttribute
64/s
View exact numbers
Test name Executions per second
getElementsByClassName 2,560,211 Ops/sec
querySelectorAll with .class 658 Ops/sec
filter with className 245 Ops/sec
filter with getAttribute 134 Ops/sec
filter with classList 126 Ops/sec
querySelectorAll with [attribute] 122 Ops/sec
for with className 88 Ops/sec
for with classList 67 Ops/sec
for with getAttribute 64 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: