Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Chrome 75
Mac OS X 10.14.4
Desktop
5 years ago
Test name Executions per second
getElementById() 4118734.2 Ops/sec
getElementsByClassName() 2491411.8 Ops/sec
getElementsByTagName() 3164159.5 Ops/sec
querySelector(#id) 2259600.8 Ops/sec
querySelector(.id) 3211924.5 Ops/sec
querySelectorAll(#id) 1094818.4 Ops/sec
querySelectorAll(.id) 1336515.4 Ops/sec
jQuery(#id) 1325227.4 Ops/sec
jQuery(.id) 649887.4 Ops/sec
jQuery(tag#id) 401584.9 Ops/sec
jQuery(tag.id) 414206.0 Ops/sec
jQuery + getElementById 1524761.9 Ops/sec
jQuery + getElementsByClassName 609499.1 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