Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Mac OS X 10.14.2
Desktop
5 years ago
Test name Executions per second
getElementById() 2244149.8 Ops/sec
getElementsByClassName() 1234292.8 Ops/sec
getElementsByTagName() 1696992.0 Ops/sec
querySelector(#id) 1273360.6 Ops/sec
querySelector(.id) 1858981.4 Ops/sec
querySelectorAll(#id) 495790.3 Ops/sec
querySelectorAll(.id) 669822.9 Ops/sec
jQuery(#id) 560844.4 Ops/sec
jQuery(.id) 217499.9 Ops/sec
jQuery(tag#id) 128991.9 Ops/sec
jQuery(tag.id) 133902.0 Ops/sec
jQuery + getElementById 814187.9 Ops/sec
jQuery + getElementsByClassName 221488.7 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