Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Chrome 75
Mac OS X 10.14.2
Desktop
5 years ago
Test name Executions per second
getElementById() 2972140.2 Ops/sec
getElementsByClassName() 1853359.2 Ops/sec
getElementsByTagName() 2284524.8 Ops/sec
querySelector(#id) 1569140.1 Ops/sec
querySelector(.id) 2569960.8 Ops/sec
querySelectorAll(#id) 908805.4 Ops/sec
querySelectorAll(.id) 1179485.1 Ops/sec
jQuery(#id) 808839.8 Ops/sec
jQuery(.id) 413458.6 Ops/sec
jQuery(tag#id) 241411.9 Ops/sec
jQuery(tag.id) 252235.1 Ops/sec
jQuery + getElementById 1161971.9 Ops/sec
jQuery + getElementsByClassName 468654.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