Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
Chrome 75
Mac OS X 10.14.6
Desktop
5 years ago
Test name Executions per second
getElementById() 3975466.0 Ops/sec
getElementsByClassName() 2428622.8 Ops/sec
getElementsByTagName() 3128970.0 Ops/sec
querySelector(#id) 2272404.8 Ops/sec
querySelector(.id) 3250860.5 Ops/sec
querySelectorAll(#id) 1109456.1 Ops/sec
querySelectorAll(.id) 1432721.1 Ops/sec
jQuery(#id) 1251891.4 Ops/sec
jQuery(.id) 507550.3 Ops/sec
jQuery(tag#id) 369417.8 Ops/sec
jQuery(tag.id) 379708.7 Ops/sec
jQuery + getElementById 1548438.6 Ops/sec
jQuery + getElementsByClassName 626534.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


;