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() 2874638.2 Ops/sec
getElementsByClassName() 1936143.5 Ops/sec
getElementsByTagName() 2481210.8 Ops/sec
querySelector(#id) 2197853.2 Ops/sec
querySelector(.id) 632865.1 Ops/sec
querySelectorAll(#id) 911139.2 Ops/sec
querySelectorAll(.id) 89880.9 Ops/sec
jQuery(#id) 1063906.2 Ops/sec
jQuery(.id) 578177.3 Ops/sec
jQuery(tag#id) 408338.2 Ops/sec
jQuery(tag.id) 69392.2 Ops/sec
jQuery + getElementById 1280794.5 Ops/sec
jQuery + getElementsByClassName 394473.8 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