Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15
Safari 17
Mac OS X 10.15.7
Desktop
10 months ago
Test name Executions per second
querySelectorAll with .class 1036.7 Ops/sec
querySelectorAll with [attribute] 366.7 Ops/sec
filter with classList 185.7 Ops/sec
filter with className 508.9 Ops/sec
filter with getAttribute 476.6 Ops/sec
for with classList 75.8 Ops/sec
for with className 146.0 Ops/sec
for with getAttribute 147.2 Ops/sec
getElementsByClassName 5878595.5 Ops/sec
Object Property 7953281.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

  • Object Property