Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0
Firefox 71
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2682031.8 Ops/sec
getElementsByClassName() 1773755.6 Ops/sec
getElementsByTagName() 2317428.2 Ops/sec
querySelector(#id) 2318016.2 Ops/sec
querySelector(.id) 2256571.2 Ops/sec
querySelectorAll(#id) 800396.8 Ops/sec
querySelectorAll(.id) 921454.2 Ops/sec
jQuery(#id) 2869247.2 Ops/sec
jQuery(.id) 771052.8 Ops/sec
jQuery(tag#id) 455216.1 Ops/sec
jQuery(tag.id) 477611.3 Ops/sec
jQuery + getElementById 1887932.4 Ops/sec
jQuery + getElementsByClassName 588685.2 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