Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Firefox 66
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2417214.5 Ops/sec
getElementsByClassName() 2184574.2 Ops/sec
getElementsByTagName() 2526117.0 Ops/sec
querySelector(#id) 2495835.2 Ops/sec
querySelector(.id) 2559406.2 Ops/sec
querySelectorAll(#id) 1049823.0 Ops/sec
querySelectorAll(.id) 1174619.6 Ops/sec
jQuery(#id) 2575235.8 Ops/sec
jQuery(.id) 828135.0 Ops/sec
jQuery(tag#id) 476941.5 Ops/sec
jQuery(tag.id) 501316.8 Ops/sec
jQuery + getElementById 1961887.6 Ops/sec
jQuery + getElementsByClassName 730490.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