Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36
Chrome 72
Mac OS X 10.14.3
Desktop
5 years ago
Test name Executions per second
getElementById() 3868390.5 Ops/sec
getElementsByClassName() 2507274.2 Ops/sec
getElementsByTagName() 2912473.8 Ops/sec
querySelector(#id) 2091993.8 Ops/sec
querySelector(.id) 3074048.0 Ops/sec
querySelectorAll(#id) 749345.9 Ops/sec
querySelectorAll(.id) 1018202.1 Ops/sec
jQuery(#id) 1302140.9 Ops/sec
jQuery(.id) 671999.9 Ops/sec
jQuery(tag#id) 334565.8 Ops/sec
jQuery(tag.id) 361300.7 Ops/sec
jQuery + getElementById 1484769.5 Ops/sec
jQuery + getElementsByClassName 548617.9 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