Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36
Chrome 68
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2663686.2 Ops/sec
getElementsByClassName() 1787500.1 Ops/sec
getElementsByTagName() 2050218.0 Ops/sec
querySelector(#id) 1462220.1 Ops/sec
querySelector(.id) 2023752.0 Ops/sec
querySelectorAll(#id) 647029.7 Ops/sec
querySelectorAll(.id) 729817.9 Ops/sec
jQuery(#id) 650009.3 Ops/sec
jQuery(.id) 218041.9 Ops/sec
jQuery(tag#id) 137718.6 Ops/sec
jQuery(tag.id) 133838.4 Ops/sec
jQuery + getElementById 1013930.6 Ops/sec
jQuery + getElementsByClassName 246824.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