Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0
Firefox 50
Windows
Other
7 years ago
Test name Executions per second
getElementById() 11789151.0 Ops/sec
getElementsByClassName() 4129465.8 Ops/sec
getElementsByTagName() 5506189.0 Ops/sec
querySelector(#id) 6257680.5 Ops/sec
querySelector(.id) 488438.8 Ops/sec
querySelectorAll(#id) 1517828.4 Ops/sec
querySelectorAll(.id) 61707.6 Ops/sec
jQuery(#id) 2152644.2 Ops/sec
jQuery(.id) 428005.6 Ops/sec
jQuery(tag#id) 276714.4 Ops/sec
jQuery(tag.id) 50782.0 Ops/sec
jQuery + getElementById 2430605.8 Ops/sec
jQuery + getElementsByClassName 590306.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