Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36
Chrome 78
Mac OS X 10.14.6
Desktop
5 years ago
Test name Executions per second
getElementById() 4408277.0 Ops/sec
getElementsByClassName() 2368125.8 Ops/sec
getElementsByTagName() 3138066.8 Ops/sec
querySelector(#id) 2075684.0 Ops/sec
querySelector(.id) 3086914.8 Ops/sec
querySelectorAll(#id) 886883.1 Ops/sec
querySelectorAll(.id) 992679.5 Ops/sec
jQuery(#id) 1145150.5 Ops/sec
jQuery(.id) 563523.9 Ops/sec
jQuery(tag#id) 379502.8 Ops/sec
jQuery(tag.id) 411320.0 Ops/sec
jQuery + getElementById 1561790.5 Ops/sec
jQuery + getElementsByClassName 419581.6 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


;