Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0
Firefox 133
Ubuntu
Desktop
2 months ago
Test name Executions per second
querySelectorAll with .class 765.2 Ops/sec
querySelectorAll with [attribute] 492.0 Ops/sec
filter with classList 194.7 Ops/sec
filter with className 246.8 Ops/sec
filter with getAttribute 281.2 Ops/sec
for with classList 54.1 Ops/sec
for with className 69.9 Ops/sec
for with getAttribute 76.1 Ops/sec
getElementsByClassName 2311767.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