Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
getElementById() 2318135.2 Ops/sec
getElementsByClassName() 1553661.9 Ops/sec
getElementsByTagName() 1820880.5 Ops/sec
querySelector(#id) 1320501.2 Ops/sec
querySelector(.id) 1931828.1 Ops/sec
querySelectorAll(#id) 486888.6 Ops/sec
querySelectorAll(.id) 661533.5 Ops/sec
jQuery(#id) 560457.8 Ops/sec
jQuery(.id) 193183.3 Ops/sec
jQuery(tag#id) 119692.7 Ops/sec
jQuery(tag.id) 108030.2 Ops/sec
jQuery + getElementById 662443.4 Ops/sec
jQuery + getElementsByClassName 179177.9 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