Run details:
Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
Chrome 70
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 592061.4 Ops/sec
getElementsByClassName() 377553.0 Ops/sec
getElementsByTagName() 453737.9 Ops/sec
querySelector(#id) 335369.1 Ops/sec
querySelector(.id) 457882.6 Ops/sec
querySelectorAll(#id) 137898.2 Ops/sec
querySelectorAll(.id) 173536.1 Ops/sec
jQuery(#id) 116987.8 Ops/sec
jQuery(.id) 65897.0 Ops/sec
jQuery(tag#id) 40866.1 Ops/sec
jQuery(tag.id) 42581.0 Ops/sec
jQuery + getElementById 195887.4 Ops/sec
jQuery + getElementsByClassName 48562.7 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