Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Chrome 73
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3450275.8 Ops/sec
getElementsByClassName() 2103909.8 Ops/sec
getElementsByTagName() 2689172.2 Ops/sec
querySelector(#id) 2013191.2 Ops/sec
querySelector(.id) 2695940.0 Ops/sec
querySelectorAll(#id) 815812.0 Ops/sec
querySelectorAll(.id) 996305.0 Ops/sec
jQuery(#id) 1217435.4 Ops/sec
jQuery(.id) 579132.3 Ops/sec
jQuery(tag#id) 331722.3 Ops/sec
jQuery(tag.id) 356457.9 Ops/sec
jQuery + getElementById 1288821.9 Ops/sec
jQuery + getElementsByClassName 529439.1 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


;