Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Chrome 70
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 2885657.5 Ops/sec
getElementsByClassName() 1849340.4 Ops/sec
getElementsByTagName() 2249000.0 Ops/sec
querySelector(#id) 1713732.0 Ops/sec
querySelector(.id) 2323229.5 Ops/sec
querySelectorAll(#id) 671338.6 Ops/sec
querySelectorAll(.id) 853179.6 Ops/sec
jQuery(#id) 1060088.5 Ops/sec
jQuery(.id) 533682.9 Ops/sec
jQuery(tag#id) 302108.1 Ops/sec
jQuery(tag.id) 302046.9 Ops/sec
jQuery + getElementById 1146156.5 Ops/sec
jQuery + getElementsByClassName 456618.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