Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Chrome 68
Windows
Desktop
6 years ago
Test name Executions per second
getElementById() 1709947.0 Ops/sec
getElementsByClassName() 976262.8 Ops/sec
getElementsByTagName() 1310330.1 Ops/sec
querySelector(#id) 1045962.2 Ops/sec
querySelector(.id) 1255881.5 Ops/sec
querySelectorAll(#id) 494706.1 Ops/sec
querySelectorAll(.id) 595054.8 Ops/sec
jQuery(#id) 640397.9 Ops/sec
jQuery(.id) 241404.8 Ops/sec
jQuery(tag#id) 191868.0 Ops/sec
jQuery(tag.id) 157865.2 Ops/sec
jQuery + getElementById 661404.2 Ops/sec
jQuery + getElementsByClassName 172292.1 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


;