Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
Chrome 72
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 1822044.1 Ops/sec
getElementsByClassName() 1195926.6 Ops/sec
getElementsByTagName() 1457020.9 Ops/sec
querySelector(#id) 958888.6 Ops/sec
querySelector(.id) 1316215.8 Ops/sec
querySelectorAll(#id) 445444.5 Ops/sec
querySelectorAll(.id) 561739.4 Ops/sec
jQuery(#id) 502864.7 Ops/sec
jQuery(.id) 32455.5 Ops/sec
jQuery(tag#id) 16001.8 Ops/sec
jQuery(tag.id) 3013.6 Ops/sec
jQuery + getElementById 218682.5 Ops/sec
jQuery + getElementsByClassName 287451.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