Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36
Chrome 89
Windows
Desktop
3 years ago
Test name Executions per second
getElementById 3340902.5 Ops/sec
jQuery (tag.id) 562693.9 Ops/sec
jQuery (tag#id) 503682.5 Ops/sec
jQuery (.id) 815218.2 Ops/sec
jQuery (#id) 1740718.0 Ops/sec
Cash + getElementsByClassName 857847.2 Ops/sec
Cash + getElementById 1330854.6 Ops/sec
Cash (tag.id) 785171.2 Ops/sec
jQuery + getElementById 1386036.2 Ops/sec
Cash (tag#id) 677746.4 Ops/sec
Cash (#id) 1969906.9 Ops/sec
querySelectorAll (.id) 1505548.1 Ops/sec
querySelectorAll (#id) 1088063.4 Ops/sec
querySelector (.id) 2550390.2 Ops/sec
querySelector (#id) 1749938.2 Ops/sec
getElementsByTagName 2788777.5 Ops/sec
getElementsByClassName 1825733.1 Ops/sec
Cash (.id) 973636.5 Ops/sec
jQuery + getElementsByClassName 553197.1 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