Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0
Firefox 89
Linux
Desktop
3 years ago
Test name Executions per second
querySelectorAll with .class 348.8 Ops/sec
querySelectorAll with [attribute] 198.1 Ops/sec
filter with classList 54.8 Ops/sec
filter with className 67.2 Ops/sec
filter with getAttribute 99.2 Ops/sec
for with classList 24.8 Ops/sec
for with className 27.9 Ops/sec
for with getAttribute 31.3 Ops/sec
getElementsByClassName 1239872.1 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