Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
Chrome 70
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 1500612.5 Ops/sec
getElementsByClassName() 1247081.9 Ops/sec
getElementsByTagName() 1474078.2 Ops/sec
querySelector(#id) 1244494.5 Ops/sec
querySelector(.id) 1491276.4 Ops/sec
querySelectorAll(#id) 465025.5 Ops/sec
querySelectorAll(.id) 481614.9 Ops/sec
jQuery(#id) 668970.6 Ops/sec
jQuery(.id) 326650.9 Ops/sec
jQuery(tag#id) 153380.6 Ops/sec
jQuery(tag.id) 216890.5 Ops/sec
jQuery + getElementById 803775.8 Ops/sec
jQuery + getElementsByClassName 248361.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