Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
Chrome 79
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 4289447.0 Ops/sec
getElementsByClassName() 2594355.0 Ops/sec
getElementsByTagName() 3576867.2 Ops/sec
querySelector(#id) 2544105.8 Ops/sec
querySelector(.id) 3564224.0 Ops/sec
querySelectorAll(#id) 1324621.2 Ops/sec
querySelectorAll(.id) 1690294.0 Ops/sec
jQuery(#id) 1387395.6 Ops/sec
jQuery(.id) 655290.1 Ops/sec
jQuery(tag#id) 427312.5 Ops/sec
jQuery(tag.id) 447808.6 Ops/sec
jQuery + getElementById 1725984.0 Ops/sec
jQuery + getElementsByClassName 617323.0 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