Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36
Chrome 78
Mac OS X 10.14.6
Desktop
5 years ago
Test name Executions per second
getElementById() 3296987.8 Ops/sec
getElementsByClassName() 1863836.9 Ops/sec
getElementsByTagName() 2477473.2 Ops/sec
querySelector(#id) 1498414.1 Ops/sec
querySelector(.id) 2302227.0 Ops/sec
querySelectorAll(#id) 711923.8 Ops/sec
querySelectorAll(.id) 1003613.6 Ops/sec
jQuery(#id) 838558.2 Ops/sec
jQuery(.id) 415512.6 Ops/sec
jQuery(tag#id) 259893.6 Ops/sec
jQuery(tag.id) 286652.7 Ops/sec
jQuery + getElementById 1144717.1 Ops/sec
jQuery + getElementsByClassName 389316.7 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