Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Chrome 70
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 1933562.4 Ops/sec
getElementsByClassName() 1152523.6 Ops/sec
getElementsByTagName() 1464763.2 Ops/sec
querySelector(#id) 1212786.4 Ops/sec
querySelector(.id) 1473608.9 Ops/sec
querySelectorAll(#id) 510223.6 Ops/sec
querySelectorAll(.id) 670219.1 Ops/sec
jQuery(#id) 769427.2 Ops/sec
jQuery(.id) 372168.2 Ops/sec
jQuery(tag#id) 223726.4 Ops/sec
jQuery(tag.id) 190419.2 Ops/sec
jQuery + getElementById 557189.9 Ops/sec
jQuery + getElementsByClassName 228026.9 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