Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
Chrome 72
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 4479387.0 Ops/sec
getElementsByClassName() 2744007.0 Ops/sec
getElementsByTagName() 3479240.8 Ops/sec
querySelector(#id) 2413446.2 Ops/sec
querySelector(.id) 3380542.5 Ops/sec
querySelectorAll(#id) 884773.8 Ops/sec
querySelectorAll(.id) 1213441.9 Ops/sec
jQuery(#id) 1583219.4 Ops/sec
jQuery(.id) 745677.9 Ops/sec
jQuery(tag#id) 408230.8 Ops/sec
jQuery(tag.id) 442373.8 Ops/sec
jQuery + getElementById 1682148.0 Ops/sec
jQuery + getElementsByClassName 652097.5 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