Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
Chrome 79
Mac OS X 10.15.1
Desktop
4 years ago
Test name Executions per second
getElementById() 4603522.0 Ops/sec
getElementsByClassName() 2840169.2 Ops/sec
getElementsByTagName() 3747315.0 Ops/sec
querySelector(#id) 2374006.5 Ops/sec
querySelector(.id) 3575685.0 Ops/sec
querySelectorAll(#id) 1210525.9 Ops/sec
querySelectorAll(.id) 1678208.4 Ops/sec
jQuery(#id) 1349694.1 Ops/sec
jQuery(.id) 655866.4 Ops/sec
jQuery(tag#id) 453146.8 Ops/sec
jQuery(tag.id) 478148.2 Ops/sec
jQuery + getElementById 1773262.0 Ops/sec
jQuery + getElementsByClassName 634281.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