Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
IE 11
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 833251.1 Ops/sec
getElementsByClassName() 648221.9 Ops/sec
getElementsByTagName() 651122.7 Ops/sec
querySelector(#id) 590743.6 Ops/sec
querySelector(.id) 413007.8 Ops/sec
querySelectorAll(#id) 292642.9 Ops/sec
querySelectorAll(.id) 272532.3 Ops/sec
jQuery(#id) 588944.2 Ops/sec
jQuery(.id) 177060.3 Ops/sec
jQuery(tag#id) 94518.9 Ops/sec
jQuery(tag.id) 89563.6 Ops/sec
jQuery + getElementById 616980.4 Ops/sec
jQuery + getElementsByClassName 132021.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