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 OPR/55.0.2994.61
Opera 55
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2999245.0 Ops/sec
getElementsByClassName() 1892355.4 Ops/sec
getElementsByTagName() 2288039.0 Ops/sec
querySelector(#id) 1728984.9 Ops/sec
querySelector(.id) 2362344.8 Ops/sec
querySelectorAll(#id) 782365.9 Ops/sec
querySelectorAll(.id) 898571.9 Ops/sec
jQuery(#id) 1024032.2 Ops/sec
jQuery(.id) 494493.8 Ops/sec
jQuery(tag#id) 258447.0 Ops/sec
jQuery(tag.id) 266284.2 Ops/sec
jQuery + getElementById 1104115.6 Ops/sec
jQuery + getElementsByClassName 388685.1 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