Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0
Firefox 128
Mac OS X 10.15
Desktop
2 months ago
Test name Executions per second
querySelectorAll with .class 593.3 Ops/sec
querySelectorAll with [attribute] 388.7 Ops/sec
filter with classList 108.7 Ops/sec
filter with className 141.6 Ops/sec
filter with getAttribute 170.2 Ops/sec
for with classList 28.9 Ops/sec
for with className 32.2 Ops/sec
for with getAttribute 37.4 Ops/sec
getElementsByClassName 1424263.8 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests:
  • querySelectorAll with .class

  • querySelectorAll with [attribute]

  • filter with classList

  • filter with className

  • filter with getAttribute

  • for with classList

  • for with className

  • for with getAttribute

  • getElementsByClassName