Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1
Mobile Safari 12
iOS 12.1.4
Mobile
5 years ago
Test name Executions per second
getElementById() 2619544.8 Ops/sec
getElementsByClassName() 2903412.2 Ops/sec
getElementsByTagName() 2974517.0 Ops/sec
querySelector(#id) 1864659.4 Ops/sec
querySelector(.id) 1884003.1 Ops/sec
querySelectorAll(#id) 1739144.2 Ops/sec
querySelectorAll(.id) 1521641.1 Ops/sec
jQuery(#id) 1401958.0 Ops/sec
jQuery(.id) 576013.1 Ops/sec
jQuery(tag#id) 441948.1 Ops/sec
jQuery(tag.id) 501717.1 Ops/sec
jQuery + getElementById 1164725.5 Ops/sec
jQuery + getElementsByClassName 836981.0 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