Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2903505.0 Ops/sec
getElementsByClassName() 1542103.1 Ops/sec
getElementsByTagName() 1476659.8 Ops/sec
querySelector(#id) 1498498.8 Ops/sec
querySelector(.id) 2254961.8 Ops/sec
querySelectorAll(#id) 865852.9 Ops/sec
querySelectorAll(.id) 1129183.0 Ops/sec
jQuery(#id) 569554.6 Ops/sec
jQuery(.id) 256581.3 Ops/sec
jQuery(tag#id) 123207.2 Ops/sec
jQuery(tag.id) 142752.6 Ops/sec
jQuery + getElementById 904900.9 Ops/sec
jQuery + getElementsByClassName 212413.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