Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15
Safari 13
Mac OS X 10.15.4
Desktop
4 years ago
Test name Executions per second
getElementById 3640083.8 Ops/sec
jQuery (tag.id) 833857.9 Ops/sec
jQuery (tag#id) 826234.8 Ops/sec
jQuery (.id) 1077652.5 Ops/sec
jQuery (#id) 2037734.6 Ops/sec
Cash + getElementsByClassName 1445171.5 Ops/sec
Cash + getElementById 1720774.1 Ops/sec
Cash (tag.id) 1157542.8 Ops/sec
jQuery + getElementById 1828423.1 Ops/sec
Cash (tag#id) 1158271.5 Ops/sec
Cash (#id) 2102794.5 Ops/sec
querySelectorAll (.id) 1850639.9 Ops/sec
querySelectorAll (#id) 1772698.8 Ops/sec
querySelector (.id) 2675671.2 Ops/sec
querySelector (#id) 2541929.2 Ops/sec
getElementsByTagName 3053454.0 Ops/sec
getElementsByClassName 2946499.0 Ops/sec
Cash (.id) 1426656.5 Ops/sec
jQuery + getElementsByClassName 1184374.9 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