Run details:
Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
Chrome 70
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 605854.2 Ops/sec
getElementsByClassName() 374790.7 Ops/sec
getElementsByTagName() 466607.0 Ops/sec
querySelector(#id) 342046.7 Ops/sec
querySelector(.id) 477227.4 Ops/sec
querySelectorAll(#id) 154657.6 Ops/sec
querySelectorAll(.id) 176207.4 Ops/sec
jQuery(#id) 118651.4 Ops/sec
jQuery(.id) 65521.8 Ops/sec
jQuery(tag#id) 39397.6 Ops/sec
jQuery(tag.id) 41705.7 Ops/sec
jQuery + getElementById 186228.0 Ops/sec
jQuery + getElementsByClassName 50018.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