Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36
Chrome 83
Windows
Desktop
4 years ago
Test name Executions per second
getElementById 789409.2 Ops/sec
jQuery (tag.id) 295830.6 Ops/sec
jQuery (tag#id) 280359.1 Ops/sec
jQuery (.id) 388411.2 Ops/sec
jQuery (#id) 1283634.1 Ops/sec
Cash + getElementsByClassName 677151.1 Ops/sec
Cash + getElementById 871637.8 Ops/sec
Cash (tag.id) 358823.5 Ops/sec
jQuery + getElementById 968767.2 Ops/sec
Cash (tag#id) 342524.3 Ops/sec
Cash (#id) 1235426.4 Ops/sec
querySelectorAll (.id) 1074688.2 Ops/sec
querySelectorAll (#id) 701956.2 Ops/sec
querySelector (.id) 2034001.2 Ops/sec
querySelector (#id) 824652.8 Ops/sec
getElementsByTagName 614880.7 Ops/sec
getElementsByClassName 546746.8 Ops/sec
Cash (.id) 442160.9 Ops/sec
jQuery + getElementsByClassName 390386.6 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