Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
Chrome 70
Mac OS X 10.14.0
Desktop
5 years ago
Test name Executions per second
getElementById() 3948897.2 Ops/sec
getElementsByClassName() 2515745.2 Ops/sec
getElementsByTagName() 3095322.0 Ops/sec
querySelector(#id) 2252299.8 Ops/sec
querySelector(.id) 3221075.2 Ops/sec
querySelectorAll(tag#id) 834206.2 Ops/sec
querySelectorAll(.id) 1108958.0 Ops/sec
jQuery(#id) 1421188.6 Ops/sec
jQuery(.id) 705516.2 Ops/sec
jQuery(tag#id) 357195.5 Ops/sec
jQuery(tag.id) 382349.8 Ops/sec
jQuery + getElementById 1533682.2 Ops/sec
jQuery + getElementsByClassName 602818.4 Ops/sec
HTML Preparation code:
Tests:
  • getElementById()

  • getElementsByClassName()

  • getElementsByTagName()

  • querySelector(#id)

  • querySelector(.id)

  • querySelectorAll(tag#id)

  • querySelectorAll(.id)

  • jQuery(#id)

  • jQuery(.id)

  • jQuery(tag#id)

  • jQuery(tag.id)

  • jQuery + getElementById

  • jQuery + getElementsByClassName