Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Mac OS X 10.14.0
Desktop
6 years ago
Test name Executions per second
getElementById() 3118054.2 Ops/sec
getElementsByClassName() 2003108.0 Ops/sec
getElementsByTagName() 2446622.8 Ops/sec
querySelector(#id) 1811937.5 Ops/sec
querySelector(.id) 2557047.0 Ops/sec
querySelectorAll(#id) 738237.2 Ops/sec
querySelectorAll(.id) 872237.8 Ops/sec
jQuery(#id) 1120062.2 Ops/sec
jQuery(.id) 537677.4 Ops/sec
jQuery(tag#id) 321307.5 Ops/sec
jQuery(tag.id) 327441.7 Ops/sec
jQuery + getElementById 1223115.8 Ops/sec
jQuery + getElementsByClassName 431590.1 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