Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8
Safari 10
Mac OS X 10.11.6
Other
7 years ago
Test name Executions per second
getElementById() 3466549.0 Ops/sec
getElementsByClassName() 2544997.0 Ops/sec
getElementsByTagName() 3057208.0 Ops/sec
querySelector(#id) 2513614.8 Ops/sec
querySelector(.id) 535912.1 Ops/sec
querySelectorAll(#id) 2010588.5 Ops/sec
querySelectorAll(.id) 62790.6 Ops/sec
jQuery(#id) 1964354.6 Ops/sec
jQuery(.id) 1067556.9 Ops/sec
jQuery(tag#id) 775144.9 Ops/sec
jQuery(tag.id) 66539.7 Ops/sec
jQuery + getElementById 1770990.6 Ops/sec
jQuery + getElementsByClassName 860047.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