Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Chrome 73
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2179881.5 Ops/sec
getElementsByClassName() 1433542.2 Ops/sec
getElementsByTagName() 1732189.1 Ops/sec
querySelector(#id) 1392912.6 Ops/sec
querySelector(.id) 1806771.8 Ops/sec
querySelectorAll(#id) 694033.6 Ops/sec
querySelectorAll(.id) 770981.4 Ops/sec
jQuery(#id) 924170.9 Ops/sec
jQuery(.id) 425920.9 Ops/sec
jQuery(tag#id) 258872.0 Ops/sec
jQuery(tag.id) 289878.6 Ops/sec
jQuery + getElementById 932468.9 Ops/sec
jQuery + getElementsByClassName 353619.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