Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Chrome 57
Windows
Other
7 years ago
Test name Executions per second
getElementById() 2459513.2 Ops/sec
getElementsByClassName() 1701202.2 Ops/sec
getElementsByTagName() 2022666.9 Ops/sec
querySelector(#id) 2075038.6 Ops/sec
querySelector(.id) 634124.3 Ops/sec
querySelectorAll(#id) 968209.2 Ops/sec
querySelectorAll(.id) 78924.1 Ops/sec
jQuery(#id) 967373.2 Ops/sec
jQuery(.id) 690325.8 Ops/sec
jQuery(tag#id) 449338.6 Ops/sec
jQuery(tag.id) 76444.1 Ops/sec
jQuery + getElementById 1038369.1 Ops/sec
jQuery + getElementsByClassName 355955.1 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