Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
Chrome 69
Mac OS X 10.13.6
Desktop
6 years ago
Test name Executions per second
getElementById() 3841712.8 Ops/sec
getElementsByClassName() 2559450.2 Ops/sec
getElementsByTagName() 3128990.5 Ops/sec
querySelector(#id) 2236353.8 Ops/sec
querySelector(.id) 3145957.2 Ops/sec
querySelectorAll(#id) 904910.2 Ops/sec
querySelectorAll(.id) 1131926.4 Ops/sec
jQuery(#id) 1348911.6 Ops/sec
jQuery(.id) 698552.9 Ops/sec
jQuery(tag#id) 381645.8 Ops/sec
jQuery(tag.id) 400136.5 Ops/sec
jQuery + getElementById 1515701.1 Ops/sec
jQuery + getElementsByClassName 518220.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