Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
Firefox 64
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 2221058.8 Ops/sec
getElementsByClassName() 2261696.5 Ops/sec
getElementsByTagName() 2661364.5 Ops/sec
querySelector(#id) 2556770.0 Ops/sec
querySelector(.id) 2530427.0 Ops/sec
querySelectorAll(#id) 830351.1 Ops/sec
querySelectorAll(.id) 1144994.5 Ops/sec
jQuery(#id) 2594038.0 Ops/sec
jQuery(.id) 830975.4 Ops/sec
jQuery(tag#id) 412414.1 Ops/sec
jQuery(tag.id) 413873.0 Ops/sec
jQuery + getElementById 1749978.8 Ops/sec
jQuery + getElementsByClassName 704966.3 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