Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
Firefox 62
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 1581793.0 Ops/sec
getElementsByClassName() 1716288.1 Ops/sec
getElementsByTagName() 1648572.4 Ops/sec
querySelector(#id) 1869016.1 Ops/sec
querySelector(.id) 1627823.0 Ops/sec
querySelectorAll(#id) 479634.4 Ops/sec
querySelectorAll(.id) 770220.4 Ops/sec
jQuery(#id) 1595060.9 Ops/sec
jQuery(.id) 347931.2 Ops/sec
jQuery(tag#id) 168130.1 Ops/sec
jQuery(tag.id) 189732.0 Ops/sec
jQuery + getElementById 1537131.8 Ops/sec
jQuery + getElementsByClassName 327514.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