Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36
Chrome 75
Mac OS X 10.14.5
Desktop
5 years ago
Test name Executions per second
getElementById() 4066604.0 Ops/sec
getElementsByClassName() 2561593.5 Ops/sec
getElementsByTagName() 3245097.2 Ops/sec
querySelector(#id) 2189022.0 Ops/sec
querySelector(.id) 3104289.0 Ops/sec
querySelectorAll(#id) 1092953.4 Ops/sec
querySelectorAll(.id) 1310824.5 Ops/sec
jQuery(#id) 1331333.1 Ops/sec
jQuery(.id) 678660.1 Ops/sec
jQuery(tag#id) 358522.4 Ops/sec
jQuery(tag.id) 362286.2 Ops/sec
jQuery + getElementById 1508484.8 Ops/sec
jQuery + getElementsByClassName 575393.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