Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Firefox 66
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 1854758.1 Ops/sec
getElementsByClassName() 1680187.1 Ops/sec
getElementsByTagName() 2025257.5 Ops/sec
querySelector(#id) 1994058.8 Ops/sec
querySelector(.id) 2014292.5 Ops/sec
querySelectorAll(#id) 791565.2 Ops/sec
querySelectorAll(.id) 874671.9 Ops/sec
jQuery(#id) 2287340.2 Ops/sec
jQuery(.id) 645863.4 Ops/sec
jQuery(tag#id) 374657.2 Ops/sec
jQuery(tag.id) 395559.1 Ops/sec
jQuery + getElementById 1575376.2 Ops/sec
jQuery + getElementsByClassName 569703.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