Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
Firefox 60
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2493678.0 Ops/sec
getElementsByClassName() 2181106.0 Ops/sec
getElementsByTagName() 2486816.8 Ops/sec
querySelector(#id) 2385083.0 Ops/sec
querySelector(.id) 2374430.0 Ops/sec
querySelectorAll(#id) 678469.8 Ops/sec
querySelectorAll(.id) 939551.4 Ops/sec
jQuery(#id) 2215756.2 Ops/sec
jQuery(.id) 693647.0 Ops/sec
jQuery(tag#id) 346919.4 Ops/sec
jQuery(tag.id) 383320.4 Ops/sec
jQuery + getElementById 1988018.4 Ops/sec
jQuery + getElementsByClassName 679907.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