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() 4430575.0 Ops/sec
getElementsByClassName() 2724599.0 Ops/sec
getElementsByTagName() 3424260.2 Ops/sec
querySelector(#id) 2613533.5 Ops/sec
querySelector(.id) 3499928.5 Ops/sec
querySelectorAll(#id) 1101366.0 Ops/sec
querySelectorAll(.id) 1301256.2 Ops/sec
jQuery(#id) 1626582.9 Ops/sec
jQuery(.id) 742831.6 Ops/sec
jQuery(tag#id) 400625.5 Ops/sec
jQuery(tag.id) 430208.3 Ops/sec
jQuery + getElementById 1715143.0 Ops/sec
jQuery + getElementsByClassName 657731.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