Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36 OPR/42.0.2393.94
Opera 42
Windows
Other
7 years ago
Test name Executions per second
getElementById() 3247887.2 Ops/sec
getElementsByClassName() 2303422.2 Ops/sec
getElementsByTagName() 2632648.2 Ops/sec
querySelector(#id) 2710451.2 Ops/sec
querySelector(.id) 746938.8 Ops/sec
querySelectorAll(#id) 1260694.9 Ops/sec
querySelectorAll(.id) 113073.8 Ops/sec
jQuery(#id) 1195543.6 Ops/sec
jQuery(.id) 686590.2 Ops/sec
jQuery(tag#id) 454221.8 Ops/sec
jQuery(tag.id) 87327.9 Ops/sec
jQuery + getElementById 1292882.9 Ops/sec
jQuery + getElementsByClassName 415568.6 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