Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Chrome 61
Mac OS X 10.12.6
Other
7 years ago
Test name Executions per second
getElementById() 2874698.2 Ops/sec
getElementsByClassName() 1810855.9 Ops/sec
getElementsByTagName() 2316117.2 Ops/sec
querySelector(#id) 2416750.8 Ops/sec
querySelector(.id) 632.2 Ops/sec
querySelectorAll(#id) 920833.3 Ops/sec
querySelectorAll(.id) 643.8 Ops/sec
jQuery(#id) 1147637.8 Ops/sec
jQuery(.id) 579961.5 Ops/sec
jQuery(tag#id) 338174.8 Ops/sec
jQuery(tag.id) 585.9 Ops/sec
jQuery + getElementById 1250630.9 Ops/sec
jQuery + getElementsByClassName 342580.0 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