Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2073016.1 Ops/sec
getElementsByClassName() 921203.7 Ops/sec
getElementsByTagName() 1758593.4 Ops/sec
querySelector(#id) 1001362.7 Ops/sec
querySelector(.id) 1361814.2 Ops/sec
querySelectorAll(#id) 459535.8 Ops/sec
querySelectorAll(.id) 549116.9 Ops/sec
jQuery(#id) 576476.0 Ops/sec
jQuery(.id) 214438.0 Ops/sec
jQuery(tag#id) 162543.4 Ops/sec
jQuery(tag.id) 198779.3 Ops/sec
jQuery + getElementById 668727.2 Ops/sec
jQuery + getElementsByClassName 218717.7 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