Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0
Firefox 131
Windows
Desktop
one year ago
getElementsByClassName
1.4M/s
querySelectorAll with .class
435/s
querySelectorAll with [attribute]
321/s
filter with getAttribute
183/s
filter with className
143/s
filter with classList
122/s
for with getAttribute
43/s
for with className
38/s
for with classList
36/s
View exact numbers
Test name Executions per second
getElementsByClassName 1,403,107 Ops/sec
querySelectorAll with .class 435 Ops/sec
querySelectorAll with [attribute] 321 Ops/sec
filter with getAttribute 183 Ops/sec
filter with className 143 Ops/sec
filter with classList 122 Ops/sec
for with getAttribute 43 Ops/sec
for with className 38 Ops/sec
for with classList 36 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: