Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36
Chrome 92
Windows
Desktop
3 years ago
Test name Executions per second
getElementById 2409721.0 Ops/sec
jQuery (tag.id) 224511.6 Ops/sec
jQuery (tag#id) 224125.4 Ops/sec
jQuery (.id) 308227.1 Ops/sec
jQuery (#id) 1102146.4 Ops/sec
Cash + getElementsByClassName 560404.8 Ops/sec
Cash + getElementById 861755.9 Ops/sec
Cash (tag.id) 388639.8 Ops/sec
jQuery + getElementById 963556.9 Ops/sec
Cash (tag#id) 362638.3 Ops/sec
Cash (#id) 1220432.1 Ops/sec
querySelectorAll (.id) 1223376.8 Ops/sec
querySelectorAll (#id) 836364.3 Ops/sec
querySelector (.id) 2531970.8 Ops/sec
querySelector (#id) 1569354.5 Ops/sec
getElementsByTagName 1865771.9 Ops/sec
getElementsByClassName 1635646.9 Ops/sec
Cash (.id) 427276.3 Ops/sec
jQuery + getElementsByClassName 286600.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