Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Chrome 73
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3892985.5 Ops/sec
getElementsByClassName() 2418732.2 Ops/sec
getElementsByTagName() 3134416.2 Ops/sec
querySelector(#id) 2404104.2 Ops/sec
querySelector(.id) 3178673.2 Ops/sec
querySelectorAll(#id) 917229.8 Ops/sec
querySelectorAll(.id) 1122401.2 Ops/sec
jQuery(#id) 1373897.1 Ops/sec
jQuery(.id) 697823.7 Ops/sec
jQuery(tag#id) 396385.6 Ops/sec
jQuery(tag.id) 406640.1 Ops/sec
jQuery + getElementById 1524242.0 Ops/sec
jQuery + getElementsByClassName 542520.2 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