Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Chrome 55
Linux
Other
7 years ago
Test name Executions per second
getElementById() 3181854.5 Ops/sec
getElementsByClassName() 2092128.9 Ops/sec
getElementsByTagName() 2222073.8 Ops/sec
querySelector(#id) 2697164.5 Ops/sec
querySelector(.id) 658164.7 Ops/sec
querySelectorAll(#id) 1181709.0 Ops/sec
querySelectorAll(.id) 78939.5 Ops/sec
jQuery(#id) 1158228.4 Ops/sec
jQuery(.id) 556114.5 Ops/sec
jQuery(tag#id) 369884.8 Ops/sec
jQuery(tag.id) 69404.8 Ops/sec
jQuery + getElementById 1344715.6 Ops/sec
jQuery + getElementsByClassName 375887.7 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