Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36
Chrome 68
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 2641002.8 Ops/sec
getElementsByClassName() 1775114.9 Ops/sec
getElementsByTagName() 2033544.9 Ops/sec
querySelector(#id) 1451586.0 Ops/sec
querySelector(.id) 2020662.8 Ops/sec
querySelectorAll(#id) 694233.7 Ops/sec
querySelectorAll(.id) 762833.4 Ops/sec
jQuery(#id) 690826.8 Ops/sec
jQuery(.id) 212600.7 Ops/sec
jQuery(tag#id) 131166.3 Ops/sec
jQuery(tag.id) 129619.1 Ops/sec
jQuery + getElementById 959783.8 Ops/sec
jQuery + getElementsByClassName 246473.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