Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
Firefox 50
Windows 7
Other
8 years ago
Test name Executions per second
getElementById() 8806827.0 Ops/sec
getElementsByClassName() 2901492.5 Ops/sec
getElementsByTagName() 4283492.0 Ops/sec
querySelector(#id) 4635952.0 Ops/sec
querySelector(.id) 374222.5 Ops/sec
querySelectorAll(#id) 1036656.8 Ops/sec
querySelectorAll(.id) 47427.8 Ops/sec
jQuery(#id) 1583838.5 Ops/sec
jQuery(.id) 225137.0 Ops/sec
jQuery(tag#id) 141835.2 Ops/sec
jQuery(tag.id) 32140.4 Ops/sec
jQuery + getElementById 1679294.1 Ops/sec
jQuery + getElementsByClassName 313779.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