Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393
Chrome 51
Windows
Other
7 years ago
Test name Executions per second
getElementById() 3197051.5 Ops/sec
getElementsByClassName() 2173717.5 Ops/sec
getElementsByTagName() 1768715.8 Ops/sec
querySelector(#id) 1345422.9 Ops/sec
querySelector(.id) 208299.6 Ops/sec
querySelectorAll(#id) 793698.8 Ops/sec
querySelectorAll(.id) 610446.5 Ops/sec
jQuery(#id) 518625.3 Ops/sec
jQuery(.id) 252128.8 Ops/sec
jQuery(tag#id) 33456.0 Ops/sec
jQuery(tag.id) 29089.7 Ops/sec
jQuery + getElementById 578746.6 Ops/sec
jQuery + getElementsByClassName 246170.2 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