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() 3903243.2 Ops/sec
getElementsByClassName() 2271558.5 Ops/sec
getElementsByTagName() 2952519.0 Ops/sec
querySelector(#id) 2104396.8 Ops/sec
querySelector(.id) 2862022.8 Ops/sec
querySelectorAll(#id) 1042619.8 Ops/sec
querySelectorAll(.id) 1344719.6 Ops/sec
jQuery(#id) 1155637.9 Ops/sec
jQuery(.id) 556983.2 Ops/sec
jQuery(tag#id) 378013.2 Ops/sec
jQuery(tag.id) 365895.3 Ops/sec
jQuery + getElementById 1322620.2 Ops/sec
jQuery + getElementsByClassName 497389.5 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