Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:84.0) Gecko/20100101 Firefox/84.0
Firefox 84
Mac OS X 10.14
Desktop
3 years ago
Test name Executions per second
getElementById 4823551.0 Ops/sec
jQuery (tag.id) 664153.2 Ops/sec
jQuery (tag#id) 604786.6 Ops/sec
jQuery (.id) 1128983.1 Ops/sec
jQuery (#id) 4634167.5 Ops/sec
Cash + getElementsByClassName 1621844.8 Ops/sec
Cash + getElementById 2744761.0 Ops/sec
Cash (tag.id) 913100.8 Ops/sec
jQuery + getElementById 2914414.2 Ops/sec
Cash (tag#id) 834402.0 Ops/sec
Cash (#id) 4183729.8 Ops/sec
querySelectorAll (.id) 1312373.9 Ops/sec
querySelectorAll (#id) 1233505.0 Ops/sec
querySelector (.id) 3702617.0 Ops/sec
querySelector (#id) 3846870.2 Ops/sec
getElementsByTagName 3898526.2 Ops/sec
getElementsByClassName 2639554.0 Ops/sec
Cash (.id) 1523228.9 Ops/sec
jQuery + getElementsByClassName 805765.9 Ops/sec
HTML Preparation code:
Tests:
  • getElementById

  • getElementsByClassName

  • getElementsByTagName

  • querySelector (#id)

  • querySelector (.id)

  • querySelectorAll (#id)

  • querySelectorAll (.id)

  • Cash (#id)

  • Cash (.id)

  • Cash (tag#id)

  • Cash (tag.id)

  • Cash + getElementById

  • Cash + getElementsByClassName

  • jQuery (#id)

  • jQuery (.id)

  • jQuery (tag#id)

  • jQuery (tag.id)

  • jQuery + getElementById

  • jQuery + getElementsByClassName