Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
Chrome 72
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 3810979.0 Ops/sec
getElementsByClassName() 2361392.8 Ops/sec
getElementsByTagName() 2978313.0 Ops/sec
querySelector(#id) 2209871.5 Ops/sec
querySelector(.id) 3040938.5 Ops/sec
querySelectorAll(#id) 895185.9 Ops/sec
querySelectorAll(.id) 1136717.8 Ops/sec
jQuery(#id) 1444184.0 Ops/sec
jQuery(.id) 691192.4 Ops/sec
jQuery(tag#id) 356875.0 Ops/sec
jQuery(tag.id) 400321.5 Ops/sec
jQuery + getElementById 1552214.8 Ops/sec
jQuery + getElementsByClassName 577602.6 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


;