Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0
Firefox 72
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 3886279.8 Ops/sec
getElementsByClassName() 2528262.5 Ops/sec
getElementsByTagName() 3205120.0 Ops/sec
querySelector(#id) 3052276.5 Ops/sec
querySelector(.id) 3106297.5 Ops/sec
querySelectorAll(#id) 1211760.4 Ops/sec
querySelectorAll(.id) 1322609.4 Ops/sec
jQuery(#id) 4533096.5 Ops/sec
jQuery(.id) 1030376.8 Ops/sec
jQuery(tag#id) 622633.1 Ops/sec
jQuery(tag.id) 657061.7 Ops/sec
jQuery + getElementById 2951644.0 Ops/sec
jQuery + getElementsByClassName 902980.9 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