Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36
Chrome 75
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 1749752.8 Ops/sec
getElementsByClassName() 1079562.1 Ops/sec
getElementsByTagName() 1366691.0 Ops/sec
querySelector(#id) 974678.8 Ops/sec
querySelector(.id) 1385508.5 Ops/sec
querySelectorAll(#id) 431061.8 Ops/sec
querySelectorAll(.id) 585823.2 Ops/sec
jQuery(#id) 366733.7 Ops/sec
jQuery(.id) 159141.8 Ops/sec
jQuery(tag#id) 99893.1 Ops/sec
jQuery(tag.id) 97874.4 Ops/sec
jQuery + getElementById 543745.4 Ops/sec
jQuery + getElementsByClassName 189008.6 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


;