Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36 Edg/91.0.864.37
Chrome 91
Windows
Desktop
3 years ago
Test name Executions per second
getElementById 3312480.8 Ops/sec
jQuery (tag.id) 158099.6 Ops/sec
jQuery (tag#id) 171633.8 Ops/sec
jQuery (.id) 238235.0 Ops/sec
jQuery (#id) 1062234.6 Ops/sec
Cash + getElementsByClassName 1059541.6 Ops/sec
Cash + getElementById 1279994.2 Ops/sec
Cash (tag.id) 772122.8 Ops/sec
jQuery + getElementById 637030.6 Ops/sec
Cash (tag#id) 669277.3 Ops/sec
Cash (#id) 1968648.5 Ops/sec
querySelectorAll (.id) 1686343.4 Ops/sec
querySelectorAll (#id) 1167718.9 Ops/sec
querySelector (.id) 3458487.5 Ops/sec
querySelector (#id) 2035498.6 Ops/sec
getElementsByTagName 2715259.0 Ops/sec
getElementsByClassName 2247864.5 Ops/sec
Cash (.id) 935604.3 Ops/sec
jQuery + getElementsByClassName 274321.4 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