Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36
Chrome 86
Windows
Desktop
4 years ago
Test name Executions per second
getElementById 2727370.0 Ops/sec
jQuery (tag.id) 335010.8 Ops/sec
jQuery (tag#id) 315368.9 Ops/sec
jQuery (.id) 424228.2 Ops/sec
jQuery (#id) 1325965.8 Ops/sec
Cash + getElementsByClassName 734869.3 Ops/sec
Cash + getElementById 1050901.2 Ops/sec
Cash (tag.id) 402403.5 Ops/sec
jQuery + getElementById 1074922.1 Ops/sec
Cash (tag#id) 373988.8 Ops/sec
Cash (#id) 1537561.1 Ops/sec
querySelectorAll (.id) 1222026.5 Ops/sec
querySelectorAll (#id) 868551.3 Ops/sec
querySelector (.id) 2761983.2 Ops/sec
querySelector (#id) 1654471.4 Ops/sec
getElementsByTagName 2081392.0 Ops/sec
getElementsByClassName 1741210.4 Ops/sec
Cash (.id) 504593.2 Ops/sec
jQuery + getElementsByClassName 460214.2 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