Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0
Firefox 65
Mac OS X 10.14
Desktop
5 years ago
Test name Executions per second
getElementById() 322908.3 Ops/sec
getElementsByClassName() 2822227.8 Ops/sec
getElementsByTagName() 458494.5 Ops/sec
querySelector(#id) 496367.2 Ops/sec
querySelector(.id) 493093.2 Ops/sec
querySelectorAll(#id) 155627.8 Ops/sec
querySelectorAll(.id) 154669.8 Ops/sec
jQuery(#id) 51655.4 Ops/sec
jQuery(.id) 49074.6 Ops/sec
jQuery(tag#id) 71833.0 Ops/sec
jQuery(tag.id) 76098.9 Ops/sec
jQuery + getElementById 254316.1 Ops/sec
jQuery + getElementsByClassName 215314.2 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