Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Chrome 85
Windows
Desktop
4 years ago
Test name Executions per second
getElementById 2453809.0 Ops/sec
jQuery (tag.id) 338032.7 Ops/sec
jQuery (tag#id) 320188.0 Ops/sec
jQuery (.id) 457256.2 Ops/sec
jQuery (#id) 1455664.5 Ops/sec
Cash + getElementsByClassName 788137.5 Ops/sec
Cash + getElementById 1083231.2 Ops/sec
Cash (tag.id) 464164.1 Ops/sec
jQuery + getElementById 1083317.1 Ops/sec
Cash (tag#id) 419800.8 Ops/sec
Cash (#id) 1566992.9 Ops/sec
querySelectorAll (.id) 1506835.5 Ops/sec
querySelectorAll (#id) 1072193.9 Ops/sec
querySelector (.id) 2464006.2 Ops/sec
querySelector (#id) 1666445.9 Ops/sec
getElementsByTagName 2074231.0 Ops/sec
getElementsByClassName 1799314.9 Ops/sec
Cash (.id) 542973.7 Ops/sec
jQuery + getElementsByClassName 430649.6 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