Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Mac OS X 10.14.2
Desktop
6 years ago
Test name Executions per second
getElementById() 4217805.5 Ops/sec
getElementsByClassName() 2706676.5 Ops/sec
getElementsByTagName() 3331205.8 Ops/sec
querySelector(#id) 2378708.8 Ops/sec
querySelector(.id) 3384048.2 Ops/sec
querySelectorAll(#id) 761860.3 Ops/sec
querySelectorAll(.id) 793517.6 Ops/sec
jQuery(#id) 1195461.9 Ops/sec
jQuery(.id) 496718.7 Ops/sec
jQuery(tag#id) 291091.9 Ops/sec
jQuery(tag.id) 365347.7 Ops/sec
jQuery + getElementById 1538763.2 Ops/sec
jQuery + getElementsByClassName 583431.8 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