Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
Chrome 79
Windows
Desktop
4 years ago
Test name Executions per second
getElementById() 3733052.0 Ops/sec
getElementsByClassName() 1989863.1 Ops/sec
getElementsByTagName() 2457912.5 Ops/sec
querySelector(#id) 1895370.6 Ops/sec
querySelector(.id) 2726142.8 Ops/sec
querySelectorAll(#id) 927410.1 Ops/sec
querySelectorAll(.id) 1308113.5 Ops/sec
jQuery(#id) 1135268.5 Ops/sec
jQuery(.id) 510403.9 Ops/sec
jQuery(tag#id) 357210.3 Ops/sec
jQuery(tag.id) 339273.6 Ops/sec
jQuery + getElementById 1303615.5 Ops/sec
jQuery + getElementsByClassName 512396.4 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