Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36
Chrome 75
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2567922.5 Ops/sec
getElementsByClassName() 1579027.8 Ops/sec
getElementsByTagName() 2100711.0 Ops/sec
querySelector(#id) 1519524.5 Ops/sec
querySelector(.id) 2105544.2 Ops/sec
querySelectorAll(#id) 725078.8 Ops/sec
querySelectorAll(.id) 906784.4 Ops/sec
jQuery(#id) 755003.8 Ops/sec
jQuery(.id) 404467.4 Ops/sec
jQuery(tag#id) 266573.7 Ops/sec
jQuery(tag.id) 274196.5 Ops/sec
jQuery + getElementById 1001050.4 Ops/sec
jQuery + getElementsByClassName 368409.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