Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0
Firefox 74
Windows 8.1
Desktop
4 years ago
Test name Executions per second
getElementById 3423362.0 Ops/sec
jQuery (tag.id) 314671.3 Ops/sec
jQuery (tag#id) 323463.8 Ops/sec
jQuery (.id) 598875.6 Ops/sec
jQuery (#id) 2633980.2 Ops/sec
Cash + getElementsByClassName 1245144.5 Ops/sec
Cash + getElementById 2480039.2 Ops/sec
Cash (tag.id) 939922.2 Ops/sec
jQuery + getElementById 1478392.5 Ops/sec
Cash (tag#id) 905800.4 Ops/sec
Cash (#id) 3875882.2 Ops/sec
querySelectorAll (.id) 1116350.1 Ops/sec
querySelectorAll (#id) 1021469.4 Ops/sec
querySelector (.id) 2826484.0 Ops/sec
querySelector (#id) 2741299.0 Ops/sec
getElementsByTagName 2808782.0 Ops/sec
getElementsByClassName 2263100.8 Ops/sec
Cash (.id) 1753634.6 Ops/sec
jQuery + getElementsByClassName 510853.0 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