Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
Chrome 74
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 3380704.0 Ops/sec
getElementsByClassName() 2050927.9 Ops/sec
getElementsByTagName() 2472429.2 Ops/sec
querySelector(#id) 1907997.8 Ops/sec
querySelector(.id) 2577259.0 Ops/sec
querySelectorAll(#id) 813467.0 Ops/sec
querySelectorAll(.id) 992335.5 Ops/sec
jQuery(#id) 811694.8 Ops/sec
jQuery(.id) 401204.6 Ops/sec
jQuery(tag#id) 286947.8 Ops/sec
jQuery(tag.id) 297958.9 Ops/sec
jQuery + getElementById 1240297.8 Ops/sec
jQuery + getElementsByClassName 495240.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