Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Chrome 66
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2147517.2 Ops/sec
getElementsByClassName() 1391562.1 Ops/sec
getElementsByTagName() 1743949.5 Ops/sec
querySelector(#id) 1304391.9 Ops/sec
querySelector(.id) 1761123.9 Ops/sec
querySelectorAll(#id) 630792.8 Ops/sec
querySelectorAll(.id) 717684.1 Ops/sec
jQuery(#id) 816090.9 Ops/sec
jQuery(.id) 388953.3 Ops/sec
jQuery(tag#id) 223589.4 Ops/sec
jQuery(tag.id) 201612.2 Ops/sec
jQuery + getElementById 849990.2 Ops/sec
jQuery + getElementsByClassName 302976.4 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