Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Firefox 61
Windows 8.1
Desktop
6 years ago
Test name Executions per second
getElementById() 1567274.5 Ops/sec
getElementsByClassName() 1220472.2 Ops/sec
getElementsByTagName() 1374579.9 Ops/sec
querySelector(#id) 1621171.9 Ops/sec
querySelector(.id) 1646939.0 Ops/sec
querySelectorAll(#id) 379103.0 Ops/sec
querySelectorAll(.id) 415880.8 Ops/sec
jQuery(#id) 1626418.5 Ops/sec
jQuery(.id) 203388.1 Ops/sec
jQuery(tag#id) 108743.8 Ops/sec
jQuery(tag.id) 134795.2 Ops/sec
jQuery + getElementById 1075396.5 Ops/sec
jQuery + getElementsByClassName 217746.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