Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Firefox 66
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 869117.1 Ops/sec
getElementsByClassName() 763474.7 Ops/sec
getElementsByTagName() 822968.2 Ops/sec
querySelector(#id) 873719.3 Ops/sec
querySelector(.id) 1223713.9 Ops/sec
querySelectorAll(#id) 372339.3 Ops/sec
querySelectorAll(.id) 336191.1 Ops/sec
jQuery(#id) 771964.7 Ops/sec
jQuery(.id) 222431.9 Ops/sec
jQuery(tag#id) 129136.5 Ops/sec
jQuery(tag.id) 218840.9 Ops/sec
jQuery + getElementById 399153.1 Ops/sec
jQuery + getElementsByClassName 122009.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