Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0
Firefox 61
Mac OS X 10.13
Desktop
6 years ago
Test name Executions per second
getElementById() 2588891.0 Ops/sec
getElementsByClassName() 2347221.0 Ops/sec
getElementsByTagName() 2853135.2 Ops/sec
querySelector(#id) 2687177.2 Ops/sec
querySelector(.id) 2606676.0 Ops/sec
querySelectorAll(#id) 815648.5 Ops/sec
querySelectorAll(.id) 1077337.6 Ops/sec
jQuery(#id) 2462653.5 Ops/sec
jQuery(.id) 877594.3 Ops/sec
jQuery(tag#id) 426445.4 Ops/sec
jQuery(tag.id) 444281.0 Ops/sec
jQuery + getElementById 2183020.5 Ops/sec
jQuery + getElementsByClassName 645494.8 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