Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36
Chrome 85
Windows 8.1
Desktop
4 years ago
Test name Executions per second
getElementById 1788794.1 Ops/sec
jQuery (tag.id) 260366.0 Ops/sec
jQuery (tag#id) 243088.3 Ops/sec
jQuery (.id) 340396.3 Ops/sec
jQuery (#id) 1028988.0 Ops/sec
Cash + getElementsByClassName 539957.2 Ops/sec
Cash + getElementById 719705.7 Ops/sec
Cash (tag.id) 301762.2 Ops/sec
jQuery + getElementById 790212.3 Ops/sec
Cash (tag#id) 275974.8 Ops/sec
Cash (#id) 1124253.4 Ops/sec
querySelectorAll (.id) 916599.2 Ops/sec
querySelectorAll (#id) 623783.4 Ops/sec
querySelector (.id) 1852189.5 Ops/sec
querySelector (#id) 1123154.9 Ops/sec
getElementsByTagName 1499187.0 Ops/sec
getElementsByClassName 1228977.8 Ops/sec
Cash (.id) 398936.4 Ops/sec
jQuery + getElementsByClassName 318706.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


;