Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Chrome 73
Mac OS X 10.14.2
Desktop
5 years ago
Test name Executions per second
getElementById() 2948182.2 Ops/sec
getElementsByClassName() 1987352.0 Ops/sec
getElementsByTagName() 2649717.2 Ops/sec
querySelector(#id) 1841798.2 Ops/sec
querySelector(.id) 2710778.5 Ops/sec
querySelectorAll(#id) 677124.7 Ops/sec
querySelectorAll(.id) 778587.6 Ops/sec
jQuery(#id) 697391.4 Ops/sec
jQuery(.id) 294349.4 Ops/sec
jQuery(tag#id) 162350.0 Ops/sec
jQuery(tag.id) 162641.0 Ops/sec
jQuery + getElementById 1144261.4 Ops/sec
jQuery + getElementsByClassName 282168.5 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