Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36
Chrome 79
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 4081574.2 Ops/sec
getElementsByClassName() 2347266.8 Ops/sec
getElementsByTagName() 3020223.2 Ops/sec
querySelector(#id) 2208737.0 Ops/sec
querySelector(.id) 3110590.0 Ops/sec
querySelectorAll(#id) 984591.8 Ops/sec
querySelectorAll(.id) 1378887.6 Ops/sec
jQuery(#id) 1137045.5 Ops/sec
jQuery(.id) 561519.1 Ops/sec
jQuery(tag#id) 391557.8 Ops/sec
jQuery(tag.id) 413836.7 Ops/sec
jQuery + getElementById 1432431.4 Ops/sec
jQuery + getElementsByClassName 508700.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