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() 3137526.5 Ops/sec
getElementsByClassName() 2054436.9 Ops/sec
getElementsByTagName() 1768992.9 Ops/sec
querySelector(#id) 1349204.9 Ops/sec
querySelector(.id) 218772.5 Ops/sec
querySelectorAll(#id) 767508.9 Ops/sec
querySelectorAll(.id) 637467.1 Ops/sec
jQuery(#id) 537751.8 Ops/sec
jQuery(.id) 265602.6 Ops/sec
jQuery(tag#id) 35478.4 Ops/sec
jQuery(tag.id) 30499.7 Ops/sec
jQuery + getElementById 588464.3 Ops/sec
jQuery + getElementsByClassName 246994.7 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