Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
Chrome 78
Windows 8.1
Desktop
4 years ago
Test name Executions per second
getElementById() 4879425.0 Ops/sec
getElementsByClassName() 2867562.5 Ops/sec
getElementsByTagName() 3781389.2 Ops/sec
querySelector(#id) 2714928.8 Ops/sec
querySelector(.id) 3599187.5 Ops/sec
querySelectorAll(#id) 1386657.4 Ops/sec
querySelectorAll(.id) 1737376.1 Ops/sec
jQuery(#id) 1511510.8 Ops/sec
jQuery(.id) 717626.3 Ops/sec
jQuery(tag#id) 486752.4 Ops/sec
jQuery(tag.id) 489784.1 Ops/sec
jQuery + getElementById 1767489.9 Ops/sec
jQuery + getElementsByClassName 647470.4 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


;