Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36
Chrome 78
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 4000408.5 Ops/sec
getElementsByClassName() 2365680.8 Ops/sec
getElementsByTagName() 3058375.5 Ops/sec
querySelector(#id) 2219875.0 Ops/sec
querySelector(.id) 3002254.0 Ops/sec
querySelectorAll(#id) 1061985.2 Ops/sec
querySelectorAll(.id) 1350714.2 Ops/sec
jQuery(#id) 1192175.5 Ops/sec
jQuery(.id) 544558.3 Ops/sec
jQuery(tag#id) 385048.7 Ops/sec
jQuery(tag.id) 391491.7 Ops/sec
jQuery + getElementById 1518206.0 Ops/sec
jQuery + getElementsByClassName 551334.0 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