Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Chrome 73
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2196614.0 Ops/sec
getElementsByClassName() 1274981.0 Ops/sec
getElementsByTagName() 1683107.4 Ops/sec
querySelector(#id) 1325301.0 Ops/sec
querySelector(.id) 1734292.0 Ops/sec
querySelectorAll(#id) 538006.9 Ops/sec
querySelectorAll(.id) 599560.0 Ops/sec
jQuery(#id) 725875.4 Ops/sec
jQuery(.id) 374591.9 Ops/sec
jQuery(tag#id) 226141.8 Ops/sec
jQuery(tag.id) 280863.6 Ops/sec
jQuery + getElementById 953856.4 Ops/sec
jQuery + getElementsByClassName 353043.9 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