Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 4616314.5 Ops/sec
getElementsByClassName() 2992414.8 Ops/sec
getElementsByTagName() 3623504.2 Ops/sec
querySelector(#id) 2699155.8 Ops/sec
querySelector(.id) 3756174.8 Ops/sec
querySelectorAll(#id) 1171952.0 Ops/sec
querySelectorAll(.id) 1444093.4 Ops/sec
jQuery(#id) 1624161.5 Ops/sec
jQuery(.id) 775893.4 Ops/sec
jQuery(tag#id) 456762.5 Ops/sec
jQuery(tag.id) 474427.0 Ops/sec
jQuery + getElementById 1713126.6 Ops/sec
jQuery + getElementsByClassName 556255.5 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