Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
Chrome 79
Mac OS X 10.14.6
Desktop
4 years ago
Test name Executions per second
getElementById() 3627080.2 Ops/sec
getElementsByClassName() 2014453.0 Ops/sec
getElementsByTagName() 2397925.5 Ops/sec
querySelector(#id) 1814307.9 Ops/sec
querySelector(.id) 2726056.5 Ops/sec
querySelectorAll(#id) 887022.8 Ops/sec
querySelectorAll(.id) 1148711.5 Ops/sec
jQuery(#id) 1101874.0 Ops/sec
jQuery(.id) 504042.2 Ops/sec
jQuery(tag#id) 240164.4 Ops/sec
jQuery(tag.id) 306075.7 Ops/sec
jQuery + getElementById 1237798.6 Ops/sec
jQuery + getElementsByClassName 474824.3 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