Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2654447.5 Ops/sec
getElementsByClassName() 1581588.6 Ops/sec
getElementsByTagName() 2111505.5 Ops/sec
querySelector(#id) 1524427.5 Ops/sec
querySelector(.id) 2162261.8 Ops/sec
querySelectorAll(#id) 515298.4 Ops/sec
querySelectorAll(.id) 554166.1 Ops/sec
jQuery(#id) 501689.3 Ops/sec
jQuery(.id) 212357.0 Ops/sec
jQuery(tag#id) 112405.0 Ops/sec
jQuery(tag.id) 144651.5 Ops/sec
jQuery + getElementById 887059.2 Ops/sec
jQuery + getElementsByClassName 224595.8 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