Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36
Chrome 67
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 1347214.0 Ops/sec
getElementsByClassName() 836417.6 Ops/sec
getElementsByTagName() 1249786.9 Ops/sec
querySelector(#id) 906424.5 Ops/sec
querySelector(.id) 1091053.9 Ops/sec
querySelectorAll(#id) 373344.3 Ops/sec
querySelectorAll(.id) 455661.7 Ops/sec
jQuery(#id) 473120.7 Ops/sec
jQuery(.id) 220835.1 Ops/sec
jQuery(tag#id) 146521.9 Ops/sec
jQuery(tag.id) 177219.6 Ops/sec
jQuery + getElementById 712187.8 Ops/sec
jQuery + getElementsByClassName 229861.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