Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0
Firefox 73
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 3435442.5 Ops/sec
getElementsByClassName() 2188916.2 Ops/sec
getElementsByTagName() 2790394.8 Ops/sec
querySelector(#id) 2468611.8 Ops/sec
querySelector(.id) 2406399.0 Ops/sec
querySelectorAll(#id) 1039612.2 Ops/sec
querySelectorAll(.id) 1132509.4 Ops/sec
jQuery(#id) 2685911.0 Ops/sec
jQuery(.id) 886902.7 Ops/sec
jQuery(tag#id) 409680.6 Ops/sec
jQuery(tag.id) 463960.8 Ops/sec
jQuery + getElementById 2222234.5 Ops/sec
jQuery + getElementsByClassName 581787.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