Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
Chrome 66
Mac OS X 10.13.4
Desktop
6 years ago
Test name Executions per second
getElementById() 3030390.0 Ops/sec
getElementsByClassName() 1943138.9 Ops/sec
getElementsByTagName() 2300369.0 Ops/sec
querySelector(#id) 1834743.0 Ops/sec
querySelector(.id) 2544326.2 Ops/sec
querySelectorAll(#id) 734154.9 Ops/sec
querySelectorAll(.id) 945054.9 Ops/sec
jQuery(#id) 1182060.1 Ops/sec
jQuery(.id) 481555.3 Ops/sec
jQuery(tag#id) 285550.9 Ops/sec
jQuery(tag.id) 276219.0 Ops/sec
jQuery + getElementById 1149913.2 Ops/sec
jQuery + getElementsByClassName 392217.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


;