Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36
Chrome 86
Windows
Desktop
4 years ago
Test name Executions per second
getElementById 1342570.9 Ops/sec
jQuery (tag.id) 156380.9 Ops/sec
jQuery (tag#id) 131484.7 Ops/sec
jQuery (.id) 202638.9 Ops/sec
jQuery (#id) 607951.6 Ops/sec
Cash + getElementsByClassName 276971.2 Ops/sec
Cash + getElementById 391417.1 Ops/sec
Cash (tag.id) 256412.5 Ops/sec
jQuery + getElementById 619987.4 Ops/sec
Cash (tag#id) 223043.3 Ops/sec
Cash (#id) 780991.4 Ops/sec
querySelectorAll (.id) 511561.6 Ops/sec
querySelectorAll (#id) 462014.8 Ops/sec
querySelector (.id) 1421774.8 Ops/sec
querySelector (#id) 898648.5 Ops/sec
getElementsByTagName 558116.8 Ops/sec
getElementsByClassName 852884.2 Ops/sec
Cash (.id) 302960.7 Ops/sec
jQuery + getElementsByClassName 284823.6 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