Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Chrome 55
Windows
Other
7 years ago
Test name Executions per second
getElementById() 2805013.8 Ops/sec
getElementsByClassName() 2119783.8 Ops/sec
getElementsByTagName() 2443158.8 Ops/sec
querySelector(#id) 2362539.2 Ops/sec
querySelector(.id) 555306.6 Ops/sec
querySelectorAll(#id) 1064760.9 Ops/sec
querySelectorAll(.id) 79999.6 Ops/sec
jQuery(#id) 1200783.5 Ops/sec
jQuery(.id) 572205.6 Ops/sec
jQuery(tag#id) 388620.2 Ops/sec
jQuery(tag.id) 62740.6 Ops/sec
jQuery + getElementById 1333133.4 Ops/sec
jQuery + getElementsByClassName 411854.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