Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8
Safari 10
Mac OS X 10.12.3
Other
7 years ago
Test name Executions per second
getElementById() 4350963.5 Ops/sec
getElementsByClassName() 2946480.8 Ops/sec
getElementsByTagName() 3938588.0 Ops/sec
querySelector(#id) 3165176.5 Ops/sec
querySelector(.id) 726459.2 Ops/sec
querySelectorAll(#id) 2425096.5 Ops/sec
querySelectorAll(.id) 71844.7 Ops/sec
jQuery(#id) 2128846.5 Ops/sec
jQuery(.id) 890602.3 Ops/sec
jQuery(tag#id) 665068.6 Ops/sec
jQuery(tag.id) 61169.9 Ops/sec
jQuery + getElementById 1993939.1 Ops/sec
jQuery + getElementsByClassName 826462.2 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