Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
Chrome 69
Mac OS X 10.12.6
Desktop
6 years ago
Test name Executions per second
getElementById() 2912686.5 Ops/sec
getElementsByClassName() 1776598.1 Ops/sec
getElementsByTagName() 2225287.8 Ops/sec
querySelector(#id) 1605089.4 Ops/sec
querySelector(.id) 2306814.0 Ops/sec
querySelectorAll(#id) 624426.8 Ops/sec
querySelectorAll(.id) 795170.2 Ops/sec
jQuery(#id) 838178.4 Ops/sec
jQuery(.id) 491273.8 Ops/sec
jQuery(tag#id) 263825.2 Ops/sec
jQuery(tag.id) 289468.3 Ops/sec
jQuery + getElementById 1081615.0 Ops/sec
jQuery + getElementsByClassName 331656.3 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