Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Mac OS X 10.10.5
Desktop
6 years ago
Test name Executions per second
getElementById() 3042421.5 Ops/sec
getElementsByClassName() 2143009.2 Ops/sec
getElementsByTagName() 2472291.2 Ops/sec
querySelector(#id) 1822808.9 Ops/sec
querySelector(.id) 2524270.2 Ops/sec
querySelectorAll(#id) 775043.0 Ops/sec
querySelectorAll(.id) 1002455.9 Ops/sec
jQuery(#id) 840559.1 Ops/sec
jQuery(.id) 264075.4 Ops/sec
jQuery(tag#id) 167450.0 Ops/sec
jQuery(tag.id) 164209.0 Ops/sec
jQuery + getElementById 1071444.4 Ops/sec
jQuery + getElementsByClassName 279845.2 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