Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Chrome 66
Mac OS X 10.11.6
Desktop
6 years ago
Test name Executions per second
getElementById() 2488923.2 Ops/sec
getElementsByClassName() 1613678.4 Ops/sec
getElementsByTagName() 2028247.4 Ops/sec
querySelector(#id) 1556784.6 Ops/sec
querySelector(.id) 2236099.5 Ops/sec
querySelectorAll(#id) 632587.4 Ops/sec
querySelectorAll(.id) 755041.9 Ops/sec
jQuery(#id) 981242.6 Ops/sec
jQuery(.id) 432100.6 Ops/sec
jQuery(tag#id) 217140.6 Ops/sec
jQuery(tag.id) 236170.5 Ops/sec
jQuery + getElementById 1015431.4 Ops/sec
jQuery + getElementsByClassName 314025.3 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