Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2488083.0 Ops/sec
getElementsByClassName() 1560013.9 Ops/sec
getElementsByTagName() 2028989.8 Ops/sec
querySelector(#id) 1411368.9 Ops/sec
querySelector(.id) 1977279.4 Ops/sec
querySelectorAll(#id) 581811.4 Ops/sec
querySelectorAll(.id) 669190.2 Ops/sec
jQuery(#id) 979021.5 Ops/sec
jQuery(.id) 465012.2 Ops/sec
jQuery(tag#id) 254080.8 Ops/sec
jQuery(tag.id) 260586.1 Ops/sec
jQuery + getElementById 1015852.9 Ops/sec
jQuery + getElementsByClassName 389836.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