Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Chrome 66
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2470665.2 Ops/sec
getElementsByClassName() 1594299.6 Ops/sec
getElementsByTagName() 1998535.2 Ops/sec
querySelector(#id) 1439113.0 Ops/sec
querySelector(.id) 1955348.0 Ops/sec
querySelectorAll(#id) 707316.1 Ops/sec
querySelectorAll(.id) 843849.6 Ops/sec
jQuery(#id) 984963.5 Ops/sec
jQuery(.id) 392743.3 Ops/sec
jQuery(tag#id) 233879.4 Ops/sec
jQuery(tag.id) 242723.7 Ops/sec
jQuery + getElementById 942777.7 Ops/sec
jQuery + getElementsByClassName 316964.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