Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:64.0) Gecko/20100101 Firefox/64.0
Firefox 64
Mac OS X 10.13
Desktop
6 years ago
Test name Executions per second
getElementById() 552966.8 Ops/sec
getElementsByClassName() 1067000.4 Ops/sec
getElementsByTagName() 931974.1 Ops/sec
querySelector(#id) 1175884.5 Ops/sec
querySelector(.id) 1631248.9 Ops/sec
querySelectorAll(#id) 453108.8 Ops/sec
querySelectorAll(.id) 570864.6 Ops/sec
jQuery(#id) 825133.2 Ops/sec
jQuery(.id) 402091.1 Ops/sec
jQuery(tag#id) 231704.1 Ops/sec
jQuery(tag.id) 182817.2 Ops/sec
jQuery + getElementById 879637.3 Ops/sec
jQuery + getElementsByClassName 427584.7 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