Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36
Chrome 68
Windows 8.1
Desktop
6 years ago
Test name Executions per second
getElementById() 998716.1 Ops/sec
getElementsByClassName() 606164.8 Ops/sec
getElementsByTagName() 715840.8 Ops/sec
querySelector(#id) 548428.7 Ops/sec
querySelector(.id) 796513.6 Ops/sec
querySelectorAll(#id) 233092.1 Ops/sec
querySelectorAll(.id) 325324.4 Ops/sec
jQuery(#id) 274749.0 Ops/sec
jQuery(.id) 97439.1 Ops/sec
jQuery(tag#id) 56620.7 Ops/sec
jQuery(tag.id) 58329.3 Ops/sec
jQuery + getElementById 396775.7 Ops/sec
jQuery + getElementsByClassName 103683.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