Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0
Firefox 71
Ubuntu
Desktop
4 years ago
Test name Executions per second
getElementById 2659755.2 Ops/sec
jQuery (tag.id) 198608.2 Ops/sec
jQuery (tag#id) 191099.5 Ops/sec
jQuery (.id) 446403.8 Ops/sec
jQuery (#id) 3268760.2 Ops/sec
Cash + getElementsByClassName 705593.9 Ops/sec
Cash + getElementById 1501554.6 Ops/sec
Cash (tag.id) 469889.7 Ops/sec
jQuery + getElementById 1838603.4 Ops/sec
Cash (tag#id) 447329.5 Ops/sec
Cash (#id) 3724414.5 Ops/sec
querySelectorAll (.id) 579664.3 Ops/sec
querySelectorAll (#id) 513417.7 Ops/sec
querySelector (.id) 2093581.0 Ops/sec
querySelector (#id) 2092465.6 Ops/sec
getElementsByTagName 1746702.2 Ops/sec
getElementsByClassName 1265152.8 Ops/sec
Cash (.id) 1161122.9 Ops/sec
jQuery + getElementsByClassName 345428.8 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