Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36
Chrome 73
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 2009460.1 Ops/sec
getElementsByClassName() 1116974.0 Ops/sec
getElementsByTagName() 1370050.1 Ops/sec
querySelector(#id) 1172943.8 Ops/sec
querySelector(.id) 1584216.6 Ops/sec
querySelectorAll(#id) 454455.5 Ops/sec
querySelectorAll(.id) 577941.2 Ops/sec
jQuery(#id) 433502.3 Ops/sec
jQuery(.id) 189624.1 Ops/sec
jQuery(tag#id) 123786.8 Ops/sec
jQuery(tag.id) 117775.9 Ops/sec
jQuery + getElementById 591727.8 Ops/sec
jQuery + getElementsByClassName 166848.9 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