Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
Chrome 89
Mac OS X 11.2.3
Desktop
3 years ago
Test name Executions per second
querySelectorAll with .class 379.4 Ops/sec
querySelectorAll with [attribute] 131.5 Ops/sec
filter with classList 31.4 Ops/sec
filter with className 88.4 Ops/sec
filter with getAttribute 52.0 Ops/sec
for with classList 24.2 Ops/sec
for with className 38.0 Ops/sec
for with getAttribute 29.3 Ops/sec
getElementsByClassName 1393186.6 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


;