Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36
Chromium 66
Ubuntu
Desktop
6 years ago
Test name Executions per second
getElementById() 3415941.5 Ops/sec
getElementsByClassName() 2264600.0 Ops/sec
getElementsByTagName() 2773547.8 Ops/sec
querySelector(#id) 2164263.0 Ops/sec
querySelector(.id) 2943359.2 Ops/sec
querySelectorAll(#id) 987279.6 Ops/sec
querySelectorAll(.id) 1206043.8 Ops/sec
jQuery(#id) 1269915.0 Ops/sec
jQuery(.id) 504180.9 Ops/sec
jQuery(tag#id) 322872.3 Ops/sec
jQuery(tag.id) 340454.7 Ops/sec
jQuery + getElementById 1344445.2 Ops/sec
jQuery + getElementsByClassName 447421.7 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