Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Chrome 73
Mac OS X 10.13.6
Desktop
5 years ago
Test name Executions per second
getElementById() 2602295.0 Ops/sec
getElementsByClassName() 1671172.5 Ops/sec
getElementsByTagName() 1838418.8 Ops/sec
querySelector(#id) 1263403.9 Ops/sec
querySelector(.id) 2020835.0 Ops/sec
querySelectorAll(#id) 507402.0 Ops/sec
querySelectorAll(.id) 665760.8 Ops/sec
jQuery(#id) 535571.0 Ops/sec
jQuery(.id) 234561.5 Ops/sec
jQuery(tag#id) 128251.8 Ops/sec
jQuery(tag.id) 134727.5 Ops/sec
jQuery + getElementById 894089.8 Ops/sec
jQuery + getElementsByClassName 238671.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