Run details:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
Chrome 54
Windows 7
Other
8 years ago
Test name Executions per second
getElementById() 3075899.5 Ops/sec
getElementsByClassName() 1977464.2 Ops/sec
getElementsByTagName() 2445243.2 Ops/sec
querySelector(#id) 2163795.2 Ops/sec
querySelector(.id) 639517.9 Ops/sec
querySelectorAll(#id) 1012035.6 Ops/sec
querySelectorAll(.id) 97386.2 Ops/sec
jQuery(#id) 1107363.9 Ops/sec
jQuery(.id) 659260.4 Ops/sec
jQuery(tag#id) 465011.7 Ops/sec
jQuery(tag.id) 87682.4 Ops/sec
jQuery + getElementById 1468739.0 Ops/sec
jQuery + getElementsByClassName 453537.2 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


;