Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Chrome 70
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 3270998.5 Ops/sec
getElementsByClassName() 2062738.4 Ops/sec
getElementsByTagName() 2424026.8 Ops/sec
querySelector(#id) 1794489.0 Ops/sec
querySelector(.id) 2552715.2 Ops/sec
querySelectorAll(#id) 721361.2 Ops/sec
querySelectorAll(.id) 923490.2 Ops/sec
jQuery(#id) 1003630.2 Ops/sec
jQuery(.id) 514007.3 Ops/sec
jQuery(tag#id) 297763.8 Ops/sec
jQuery(tag.id) 306073.5 Ops/sec
jQuery + getElementById 1245843.6 Ops/sec
jQuery + getElementsByClassName 493045.9 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