Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36
Chrome 74
Mac OS X 10.13.6
Desktop
5 years ago
Test name Executions per second
getElementById() 3996346.5 Ops/sec
getElementsByClassName() 2556406.8 Ops/sec
getElementsByTagName() 3132402.2 Ops/sec
querySelector(#id) 2218596.0 Ops/sec
querySelector(.id) 3236350.2 Ops/sec
querySelectorAll(#id) 832562.7 Ops/sec
querySelectorAll(.id) 1017333.1 Ops/sec
jQuery(#id) 1074859.6 Ops/sec
jQuery(.id) 619038.6 Ops/sec
jQuery(tag#id) 289365.9 Ops/sec
jQuery(tag.id) 322900.6 Ops/sec
jQuery + getElementById 1385958.0 Ops/sec
jQuery + getElementsByClassName 579086.6 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