Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
Chrome 79
Mac OS X 10.16.0
Desktop
3 years ago
Test name Executions per second
querySelectorAll class 465.5 Ops/sec
querySelectorAll with attribute 244.7 Ops/sec
filter with classList 36.6 Ops/sec
filter with className 116.1 Ops/sec
filter with getAttribute 96.4 Ops/sec
for with classList 4528983.5 Ops/sec
for with className 4590557.5 Ops/sec
for with getAttribute 4661875.5 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