Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36
Chrome 67
Linux
Desktop
6 years ago
Test name Executions per second
getElementById() 3302668.0 Ops/sec
getElementsByClassName() 2325016.2 Ops/sec
getElementsByTagName() 2737610.2 Ops/sec
querySelector(#id) 2011428.6 Ops/sec
querySelector(.id) 2817850.5 Ops/sec
querySelectorAll(#id) 785292.4 Ops/sec
querySelectorAll(.id) 970362.8 Ops/sec
jQuery(#id) 744599.2 Ops/sec
jQuery(.id) 286646.5 Ops/sec
jQuery(tag#id) 176903.5 Ops/sec
jQuery(tag.id) 173598.1 Ops/sec
jQuery + getElementById 972190.4 Ops/sec
jQuery + getElementsByClassName 279368.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