Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.0 Mobile/14G60 Safari/602.1
Mobile Safari 10
iOS 10.3.3
iPhone
7 years ago
Test name Executions per second
getElementById() 2134271.8 Ops/sec
getElementsByClassName() 1699216.8 Ops/sec
getElementsByTagName() 1879096.1 Ops/sec
querySelector(#id) 1626291.9 Ops/sec
querySelector(.id) 342690.9 Ops/sec
querySelectorAll(#id) 1215501.4 Ops/sec
querySelectorAll(.id) 47373.9 Ops/sec
jQuery(#id) 1145781.9 Ops/sec
jQuery(.id) 610123.7 Ops/sec
jQuery(tag#id) 444285.4 Ops/sec
jQuery(tag.id) 41920.8 Ops/sec
jQuery + getElementById 1022911.1 Ops/sec
jQuery + getElementsByClassName 474905.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