Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 10_1_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0 Mobile/14B100 Safari/602.1
Mobile Safari 10
iOS 10.1.1
iPhone
7 years ago
Test name Executions per second
getElementById() 4327200.0 Ops/sec
getElementsByClassName() 3336844.2 Ops/sec
getElementsByTagName() 3989208.2 Ops/sec
querySelector(#id) 3548760.8 Ops/sec
querySelector(.id) 808306.4 Ops/sec
querySelectorAll(#id) 2556487.0 Ops/sec
querySelectorAll(.id) 96646.1 Ops/sec
jQuery(#id) 2308220.8 Ops/sec
jQuery(.id) 1250055.5 Ops/sec
jQuery(tag#id) 868885.0 Ops/sec
jQuery(tag.id) 83160.6 Ops/sec
jQuery + getElementById 1982326.2 Ops/sec
jQuery + getElementsByClassName 891114.7 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