Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
Firefox 69
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2106823.8 Ops/sec
getElementsByClassName() 1577078.9 Ops/sec
getElementsByTagName() 2238632.8 Ops/sec
querySelector(#id) 2100246.2 Ops/sec
querySelector(.id) 2194718.5 Ops/sec
querySelectorAll(#id) 798130.2 Ops/sec
querySelectorAll(.id) 906439.8 Ops/sec
jQuery(#id) 2279066.5 Ops/sec
jQuery(.id) 731072.0 Ops/sec
jQuery(tag#id) 417496.3 Ops/sec
jQuery(tag.id) 441908.5 Ops/sec
jQuery + getElementById 1583059.4 Ops/sec
jQuery + getElementsByClassName 617224.6 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