Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
Chrome 72
Windows 7
Desktop
5 years ago
Test name Executions per second
getElementById() 3017181.5 Ops/sec
getElementsByClassName() 1832287.0 Ops/sec
getElementsByTagName() 2304045.5 Ops/sec
querySelector(#id) 1714141.9 Ops/sec
querySelector(.id) 2409244.2 Ops/sec
querySelectorAll(#id) 684242.6 Ops/sec
querySelectorAll(.id) 770162.6 Ops/sec
jQuery(#id) 1058081.0 Ops/sec
jQuery(.id) 501026.3 Ops/sec
jQuery(tag#id) 255905.1 Ops/sec
jQuery(tag.id) 266709.6 Ops/sec
jQuery + getElementById 1189685.2 Ops/sec
jQuery + getElementsByClassName 433203.8 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