Run details:
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Chrome 55
Windows
Other
8 years ago
Test name Executions per second
getElementById() 3123370.0 Ops/sec
getElementsByClassName() 2262618.5 Ops/sec
getElementsByTagName() 2668924.0 Ops/sec
querySelector(#id) 2520904.2 Ops/sec
querySelector(.id) 676111.9 Ops/sec
querySelectorAll(#id) 1210628.0 Ops/sec
querySelectorAll(.id) 116421.5 Ops/sec
jQuery(#id) 1138316.9 Ops/sec
jQuery(.id) 560832.3 Ops/sec
jQuery(tag#id) 304521.6 Ops/sec
jQuery(tag.id) 76820.6 Ops/sec
jQuery + getElementById 1358848.8 Ops/sec
jQuery + getElementsByClassName 356060.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