Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Firefox 61
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 735176.7 Ops/sec
getElementsByClassName() 833812.9 Ops/sec
getElementsByTagName() 969560.2 Ops/sec
querySelector(#id) 646897.4 Ops/sec
querySelector(.id) 734542.6 Ops/sec
querySelectorAll(#id) 235534.4 Ops/sec
querySelectorAll(.id) 347594.5 Ops/sec
jQuery(#id) 691378.3 Ops/sec
jQuery(.id) 255654.6 Ops/sec
jQuery(tag#id) 129463.0 Ops/sec
jQuery(tag.id) 174764.5 Ops/sec
jQuery + getElementById 773907.1 Ops/sec
jQuery + getElementsByClassName 253779.6 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