Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36 OPR/47.0.2631.55
Opera 47
Windows
Other
7 years ago
Test name Executions per second
getElementById() 2816324.5 Ops/sec
getElementsByClassName() 1832159.5 Ops/sec
getElementsByTagName() 2345725.8 Ops/sec
querySelector(#id) 2202013.5 Ops/sec
querySelector(.id) 615126.1 Ops/sec
querySelectorAll(#id) 1005529.6 Ops/sec
querySelectorAll(.id) 109829.7 Ops/sec
jQuery(#id) 1213228.9 Ops/sec
jQuery(.id) 759765.8 Ops/sec
jQuery(tag#id) 425994.2 Ops/sec
jQuery(tag.id) 86557.6 Ops/sec
jQuery + getElementById 1234016.9 Ops/sec
jQuery + getElementsByClassName 395923.8 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