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 5450416.5 Ops/sec
jQuery (tag.id) 1095024.8 Ops/sec
jQuery (tag#id) 1107041.1 Ops/sec
jQuery (.id) 1426795.8 Ops/sec
jQuery (#id) 2761653.8 Ops/sec
Cash + getElementsByClassName 2064961.4 Ops/sec
Cash + getElementById 2314473.5 Ops/sec
Cash (tag.id) 1442159.4 Ops/sec
jQuery + getElementById 2504972.0 Ops/sec
Cash (tag#id) 1473628.4 Ops/sec
Cash (#id) 2758673.2 Ops/sec
querySelectorAll (.id) 2720787.8 Ops/sec
querySelectorAll (#id) 2638819.8 Ops/sec
querySelector (.id) 4364752.0 Ops/sec
querySelector (#id) 4015650.0 Ops/sec
getElementsByTagName 4709615.5 Ops/sec
getElementsByClassName 4515073.0 Ops/sec
Cash (.id) 1923882.0 Ops/sec
jQuery + getElementsByClassName 1660932.1 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