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
8 years ago
Test name Executions per second
getElementById() 3457010.5 Ops/sec
getElementsByClassName() 2143927.8 Ops/sec
getElementsByTagName() 1826684.6 Ops/sec
querySelector(#id) 1368158.2 Ops/sec
querySelector(.id) 208276.3 Ops/sec
querySelectorAll(#id) 753891.9 Ops/sec
querySelectorAll(.id) 567078.9 Ops/sec
jQuery(#id) 524778.3 Ops/sec
jQuery(.id) 267802.1 Ops/sec
jQuery(tag#id) 34696.8 Ops/sec
jQuery(tag.id) 29764.9 Ops/sec
jQuery + getElementById 589265.8 Ops/sec
jQuery + getElementsByClassName 240458.5 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