Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 3374165.8 Ops/sec
getElementsByClassName() 2517915.5 Ops/sec
getElementsByTagName() 2835187.0 Ops/sec
querySelector(#id) 1760792.6 Ops/sec
querySelector(.id) 2656243.0 Ops/sec
querySelectorAll(#id) 719132.8 Ops/sec
querySelectorAll(.id) 888203.9 Ops/sec
jQuery(#id) 977364.5 Ops/sec
jQuery(.id) 550239.8 Ops/sec
jQuery(tag#id) 286312.0 Ops/sec
jQuery(tag.id) 313948.6 Ops/sec
jQuery + getElementById 1420275.2 Ops/sec
jQuery + getElementsByClassName 541710.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