Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Chrome 73
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2292152.8 Ops/sec
getElementsByClassName() 1480080.8 Ops/sec
getElementsByTagName() 1789087.2 Ops/sec
querySelector(#id) 1401075.1 Ops/sec
querySelector(.id) 1858346.9 Ops/sec
querySelectorAll(#id) 598630.8 Ops/sec
querySelectorAll(.id) 694333.9 Ops/sec
jQuery(#id) 786865.7 Ops/sec
jQuery(.id) 382169.5 Ops/sec
jQuery(tag#id) 234665.1 Ops/sec
jQuery(tag.id) 194873.6 Ops/sec
jQuery + getElementById 892592.1 Ops/sec
jQuery + getElementsByClassName 348005.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