Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Firefox 115
Windows 8.1
Desktop
one year ago
getElementsByClassName
1.6M/s
querySelectorAll with .class
475/s
querySelectorAll with [attribute]
274/s
filter with getAttribute
150/s
filter with className
113/s
filter with classList
94/s
for with getAttribute
40/s
for with className
35/s
for with classList
32/s
View exact numbers
Test name Executions per second
getElementsByClassName 1,644,841 Ops/sec
querySelectorAll with .class 475 Ops/sec
querySelectorAll with [attribute] 274 Ops/sec
filter with getAttribute 150 Ops/sec
filter with className 113 Ops/sec
filter with classList 94 Ops/sec
for with getAttribute 40 Ops/sec
for with className 35 Ops/sec
for with classList 32 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests: