Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15
Safari 14
Mac OS X 10.15.6
Desktop
4 years ago
Test name Executions per second
getElementById 5424748.5 Ops/sec
jQuery (tag.id) 1138302.6 Ops/sec
jQuery (tag#id) 1133636.0 Ops/sec
jQuery (.id) 1423138.6 Ops/sec
jQuery (#id) 2728953.2 Ops/sec
Cash + getElementsByClassName 1976117.5 Ops/sec
Cash + getElementById 2309968.2 Ops/sec
Cash (tag.id) 382419.1 Ops/sec
jQuery + getElementById 2467572.8 Ops/sec
Cash (tag#id) 320218.4 Ops/sec
Cash (#id) 2700535.2 Ops/sec
querySelectorAll (.id) 2682081.8 Ops/sec
querySelectorAll (#id) 2561793.2 Ops/sec
querySelector (.id) 3804375.8 Ops/sec
querySelector (#id) 3667944.8 Ops/sec
getElementsByTagName 4563482.5 Ops/sec
getElementsByClassName 4422733.5 Ops/sec
Cash (.id) 1939019.0 Ops/sec
jQuery + getElementsByClassName 1655928.5 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