Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
Chrome 78
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 1678784.2 Ops/sec
getElementsByClassName() 958507.2 Ops/sec
getElementsByTagName() 902348.1 Ops/sec
querySelector(#id) 822276.4 Ops/sec
querySelector(.id) 1139586.8 Ops/sec
querySelectorAll(#id) 536582.2 Ops/sec
querySelectorAll(.id) 687836.1 Ops/sec
jQuery(#id) 266132.8 Ops/sec
jQuery(.id) 157160.0 Ops/sec
jQuery(tag#id) 102521.8 Ops/sec
jQuery(tag.id) 185161.9 Ops/sec
jQuery + getElementById 550178.4 Ops/sec
jQuery + getElementsByClassName 129440.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