Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763
Edge 18.17763
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3410361.0 Ops/sec
getElementsByClassName() 2185138.0 Ops/sec
getElementsByTagName() 2148821.2 Ops/sec
querySelector(#id) 1808333.4 Ops/sec
querySelector(.id) 957741.1 Ops/sec
querySelectorAll(#id) 843015.2 Ops/sec
querySelectorAll(.id) 622919.8 Ops/sec
jQuery(#id) 778817.5 Ops/sec
jQuery(.id) 465060.2 Ops/sec
jQuery(tag#id) 218228.6 Ops/sec
jQuery(tag.id) 207156.6 Ops/sec
jQuery + getElementById 791510.8 Ops/sec
jQuery + getElementsByClassName 306206.4 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