Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 OPR/57.0.3098.76
Opera 57
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3332297.8 Ops/sec
getElementsByClassName() 2207057.8 Ops/sec
getElementsByTagName() 2610054.0 Ops/sec
querySelector(#id) 1906572.0 Ops/sec
querySelector(.id) 2710109.0 Ops/sec
querySelectorAll(#id) 837913.9 Ops/sec
querySelectorAll(.id) 1083503.2 Ops/sec
jQuery(#id) 1201142.4 Ops/sec
jQuery(.id) 744376.1 Ops/sec
jQuery(tag#id) 372840.5 Ops/sec
jQuery(tag.id) 403281.4 Ops/sec
jQuery + getElementById 1382652.1 Ops/sec
jQuery + getElementsByClassName 566040.2 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


;