Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
Chrome 75
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3198671.0 Ops/sec
getElementsByClassName() 1960975.1 Ops/sec
getElementsByTagName() 2433909.5 Ops/sec
querySelector(#id) 1916472.0 Ops/sec
querySelector(.id) 2635687.8 Ops/sec
querySelectorAll(#id) 957821.6 Ops/sec
querySelectorAll(.id) 1148775.5 Ops/sec
jQuery(#id) 913974.0 Ops/sec
jQuery(.id) 517722.5 Ops/sec
jQuery(tag#id) 323140.8 Ops/sec
jQuery(tag.id) 329879.9 Ops/sec
jQuery + getElementById 1109703.5 Ops/sec
jQuery + getElementsByClassName 457857.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