Run details:
Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0
Firefox 52
Windows XP
Other
7 years ago
Test name Executions per second
getElementById() 4047857.0 Ops/sec
getElementsByClassName() 1365154.0 Ops/sec
getElementsByTagName() 1964797.8 Ops/sec
querySelector(#id) 2222486.8 Ops/sec
querySelector(.id) 123702.4 Ops/sec
querySelectorAll(#id) 578692.3 Ops/sec
querySelectorAll(.id) 19453.5 Ops/sec
jQuery(#id) 742574.2 Ops/sec
jQuery(.id) 112010.9 Ops/sec
jQuery(tag#id) 68180.4 Ops/sec
jQuery(tag.id) 16307.8 Ops/sec
jQuery + getElementById 2355273.2 Ops/sec
jQuery + getElementsByClassName 147587.3 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