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() 3522052.5 Ops/sec
getElementsByClassName() 1872701.2 Ops/sec
getElementsByTagName() 2570375.8 Ops/sec
querySelector(#id) 1797509.0 Ops/sec
querySelector(.id) 2648776.8 Ops/sec
querySelectorAll(#id) 778299.0 Ops/sec
querySelectorAll(.id) 967039.5 Ops/sec
jQuery(#id) 939483.5 Ops/sec
jQuery(.id) 439253.2 Ops/sec
jQuery(tag#id) 272372.1 Ops/sec
jQuery(tag.id) 296953.4 Ops/sec
jQuery + getElementById 1113044.6 Ops/sec
jQuery + getElementsByClassName 370839.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