Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
Chrome 70
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
getElementById() 3471519.8 Ops/sec
getElementsByClassName() 2122826.0 Ops/sec
getElementsByTagName() 2756571.8 Ops/sec
querySelector(#id) 1984386.9 Ops/sec
querySelector(.id) 2762493.8 Ops/sec
querySelectorAll(#id) 671999.6 Ops/sec
querySelectorAll(.id) 802168.6 Ops/sec
jQuery(#id) 939510.3 Ops/sec
jQuery(.id) 311427.4 Ops/sec
jQuery(tag#id) 185116.4 Ops/sec
jQuery(tag.id) 183178.6 Ops/sec
jQuery + getElementById 1228407.5 Ops/sec
jQuery + getElementsByClassName 290159.6 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


;