Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
Chrome 78
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2464159.5 Ops/sec
getElementsByClassName() 1613471.0 Ops/sec
getElementsByTagName() 2072220.4 Ops/sec
querySelector(#id) 1468209.0 Ops/sec
querySelector(.id) 2112736.0 Ops/sec
querySelectorAll(#id) 841871.4 Ops/sec
querySelectorAll(.id) 931036.1 Ops/sec
jQuery(#id) 730654.1 Ops/sec
jQuery(.id) 437253.2 Ops/sec
jQuery(tag#id) 218486.9 Ops/sec
jQuery(tag.id) 168593.5 Ops/sec
jQuery + getElementById 1020456.5 Ops/sec
jQuery + getElementsByClassName 375240.7 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