Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8
Safari 10
Mac OS X 10.10.5
Desktop
6 years ago
Test name Executions per second
getElementById() 3007425.8 Ops/sec
getElementsByClassName() 2199796.5 Ops/sec
getElementsByTagName() 2560805.2 Ops/sec
querySelector(#id) 2085345.6 Ops/sec
querySelector(.id) 2311121.5 Ops/sec
querySelectorAll(#id) 1309179.6 Ops/sec
querySelectorAll(.id) 1541780.2 Ops/sec
jQuery(#id) 1711163.6 Ops/sec
jQuery(.id) 685428.0 Ops/sec
jQuery(tag#id) 326293.6 Ops/sec
jQuery(tag.id) 311344.5 Ops/sec
jQuery + getElementById 1440037.4 Ops/sec
jQuery + getElementsByClassName 645425.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


;