Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0
Firefox 67
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 2980017.5 Ops/sec
getElementsByClassName() 2479684.5 Ops/sec
getElementsByTagName() 3191695.0 Ops/sec
querySelector(#id) 2751567.5 Ops/sec
querySelector(.id) 2439161.5 Ops/sec
querySelectorAll(#id) 1169140.5 Ops/sec
querySelectorAll(.id) 1222234.4 Ops/sec
jQuery(#id) 3041838.0 Ops/sec
jQuery(.id) 902833.7 Ops/sec
jQuery(tag#id) 551315.7 Ops/sec
jQuery(tag.id) 558019.8 Ops/sec
jQuery + getElementById 2300251.0 Ops/sec
jQuery + getElementsByClassName 872535.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