Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Safari/605.1.15
Safari 13
Mac OS X 10.15
Desktop
4 years ago
Test name Executions per second
getElementById() 3835799.0 Ops/sec
getElementsByClassName() 2650803.5 Ops/sec
getElementsByTagName() 3370469.8 Ops/sec
querySelector(#id) 2453487.2 Ops/sec
querySelector(.id) 3086345.5 Ops/sec
querySelectorAll(#id) 1851128.9 Ops/sec
querySelectorAll(.id) 2219757.8 Ops/sec
jQuery(#id) 2469018.0 Ops/sec
jQuery(.id) 1137600.1 Ops/sec
jQuery(tag#id) 891379.4 Ops/sec
jQuery(tag.id) 904112.8 Ops/sec
jQuery + getElementById 1914110.6 Ops/sec
jQuery + getElementsByClassName 1207593.9 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


;