Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.58
Chrome 83
Windows
Desktop
4 years ago
Test name Executions per second
getElementById 2230249.2 Ops/sec
jQuery (tag.id) 398637.2 Ops/sec
jQuery (tag#id) 278065.7 Ops/sec
jQuery (.id) 393314.3 Ops/sec
jQuery (#id) 1266147.4 Ops/sec
Cash + getElementsByClassName 681183.7 Ops/sec
Cash + getElementById 900945.1 Ops/sec
Cash (tag.id) 624703.7 Ops/sec
jQuery + getElementById 989020.2 Ops/sec
Cash (tag#id) 337617.4 Ops/sec
Cash (#id) 1173384.4 Ops/sec
querySelectorAll (.id) 1085543.8 Ops/sec
querySelectorAll (#id) 804369.5 Ops/sec
querySelector (.id) 2378572.0 Ops/sec
querySelector (#id) 1385624.6 Ops/sec
getElementsByTagName 1719814.6 Ops/sec
getElementsByClassName 1413983.5 Ops/sec
Cash (.id) 455414.3 Ops/sec
jQuery + getElementsByClassName 379941.3 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