Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0
Firefox 52
Windows
Other
7 years ago
Test name Executions per second
getElementById() 10684890.0 Ops/sec
getElementsByClassName() 3530747.0 Ops/sec
getElementsByTagName() 4818283.0 Ops/sec
querySelector(#id) 5713243.0 Ops/sec
querySelector(.id) 417046.2 Ops/sec
querySelectorAll(#id) 1508755.0 Ops/sec
querySelectorAll(.id) 49420.7 Ops/sec
jQuery(#id) 2186094.0 Ops/sec
jQuery(.id) 419032.0 Ops/sec
jQuery(tag#id) 277713.5 Ops/sec
jQuery(tag.id) 41502.4 Ops/sec
jQuery + getElementById 2426146.0 Ops/sec
jQuery + getElementsByClassName 483355.3 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