Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Firefox/60.0
Firefox 60
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 1536749.6 Ops/sec
getElementsByClassName() 1395138.2 Ops/sec
getElementsByTagName() 1620164.8 Ops/sec
querySelector(#id) 1536355.2 Ops/sec
querySelector(.id) 1541386.8 Ops/sec
querySelectorAll(#id) 468752.2 Ops/sec
querySelectorAll(.id) 698390.8 Ops/sec
jQuery(#id) 1891438.9 Ops/sec
jQuery(.id) 404516.6 Ops/sec
jQuery(tag#id) 239444.4 Ops/sec
jQuery(tag.id) 260188.3 Ops/sec
jQuery + getElementById 1211237.8 Ops/sec
jQuery + getElementsByClassName 433565.5 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