Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 11_0_3 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A432 Safari/604.1
Mobile Safari 11
iOS 11.0.3
iPhone
7 years ago
Test name Executions per second
getElementById() 5123476.5 Ops/sec
getElementsByClassName() 4037576.0 Ops/sec
getElementsByTagName() 4184846.5 Ops/sec
querySelector(#id) 3894036.8 Ops/sec
querySelector(.id) 732000.0 Ops/sec
querySelectorAll(#id) 2859794.0 Ops/sec
querySelectorAll(.id) 92740.5 Ops/sec
jQuery(#id) 2496680.2 Ops/sec
jQuery(.id) 1471501.0 Ops/sec
jQuery(tag#id) 882566.9 Ops/sec
jQuery(tag.id) 79170.6 Ops/sec
jQuery + getElementById 2229100.5 Ops/sec
jQuery + getElementsByClassName 949977.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