Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36
Chrome 74
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 2324763.0 Ops/sec
getElementsByClassName() 1521032.1 Ops/sec
getElementsByTagName() 1946640.9 Ops/sec
querySelector(#id) 1652038.2 Ops/sec
querySelector(.id) 2154342.5 Ops/sec
querySelectorAll(#id) 752787.1 Ops/sec
querySelectorAll(.id) 969938.4 Ops/sec
jQuery(#id) 938611.0 Ops/sec
jQuery(.id) 433460.3 Ops/sec
jQuery(tag#id) 260860.0 Ops/sec
jQuery(tag.id) 289602.2 Ops/sec
jQuery + getElementById 1065726.6 Ops/sec
jQuery + getElementsByClassName 406620.3 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


;