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() 2762106.2 Ops/sec
getElementsByClassName() 1751262.1 Ops/sec
getElementsByTagName() 2198182.2 Ops/sec
querySelector(#id) 1605209.5 Ops/sec
querySelector(.id) 2159707.5 Ops/sec
querySelectorAll(#id) 645376.2 Ops/sec
querySelectorAll(.id) 732350.9 Ops/sec
jQuery(#id) 1025989.2 Ops/sec
jQuery(.id) 431016.5 Ops/sec
jQuery(tag#id) 247536.3 Ops/sec
jQuery(tag.id) 257616.2 Ops/sec
jQuery + getElementById 1064171.2 Ops/sec
jQuery + getElementsByClassName 345878.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