Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Chrome 73
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 745696.4 Ops/sec
getElementsByClassName() 439655.5 Ops/sec
getElementsByTagName() 555213.8 Ops/sec
querySelector(#id) 423646.1 Ops/sec
querySelector(.id) 589489.6 Ops/sec
querySelectorAll(#id) 217837.0 Ops/sec
querySelectorAll(.id) 207016.1 Ops/sec
jQuery(#id) 252938.4 Ops/sec
jQuery(.id) 76906.0 Ops/sec
jQuery(tag#id) 66812.3 Ops/sec
jQuery(tag.id) 71476.4 Ops/sec
jQuery + getElementById 276930.6 Ops/sec
jQuery + getElementsByClassName 97156.0 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


;