Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Chrome 70
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 3207611.0 Ops/sec
getElementsByClassName() 2116803.2 Ops/sec
getElementsByTagName() 2400086.2 Ops/sec
querySelector(#id) 2131447.0 Ops/sec
querySelector(.id) 2691716.5 Ops/sec
querySelectorAll(#id) 893141.4 Ops/sec
querySelectorAll(.id) 1192470.8 Ops/sec
jQuery(#id) 1182350.2 Ops/sec
jQuery(.id) 601149.8 Ops/sec
jQuery(tag#id) 351785.7 Ops/sec
jQuery(tag.id) 374817.9 Ops/sec
jQuery + getElementById 1406395.4 Ops/sec
jQuery + getElementsByClassName 505894.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