Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2955644.8 Ops/sec
getElementsByClassName() 1899229.1 Ops/sec
getElementsByTagName() 2374721.2 Ops/sec
querySelector(#id) 1734384.4 Ops/sec
querySelector(.id) 2302529.8 Ops/sec
querySelectorAll(#id) 770144.8 Ops/sec
querySelectorAll(.id) 900285.3 Ops/sec
jQuery(#id) 1111449.6 Ops/sec
jQuery(.id) 494918.3 Ops/sec
jQuery(tag#id) 245165.1 Ops/sec
jQuery(tag.id) 239958.3 Ops/sec
jQuery + getElementById 1130292.1 Ops/sec
jQuery + getElementsByClassName 388668.4 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