Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36
Chrome 98
Windows
Desktop
2 years ago
Test name Executions per second
querySelectorAll with .class 484.0 Ops/sec
querySelectorAll with [attribute] 205.2 Ops/sec
filter with classList 43.9 Ops/sec
filter with className 104.5 Ops/sec
filter with getAttribute 61.4 Ops/sec
for with classList 25.8 Ops/sec
for with className 37.2 Ops/sec
for with getAttribute 30.4 Ops/sec
getElementsByClassName 1433260.2 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


;