Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Chrome 66
Mac OS X 10.12.6
Desktop
6 years ago
Test name Executions per second
getElementById() 1968547.1 Ops/sec
getElementsByClassName() 1262610.8 Ops/sec
getElementsByTagName() 1589666.0 Ops/sec
querySelector(#id) 1257006.4 Ops/sec
querySelector(.id) 1741353.4 Ops/sec
querySelectorAll(#id) 539557.8 Ops/sec
querySelectorAll(.id) 702073.9 Ops/sec
jQuery(#id) 454800.8 Ops/sec
jQuery(.id) 165678.6 Ops/sec
jQuery(tag#id) 105287.5 Ops/sec
jQuery(tag.id) 100044.4 Ops/sec
jQuery + getElementById 740196.1 Ops/sec
jQuery + getElementsByClassName 152932.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


;