Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Chrome 71
Windows
Desktop
5 years ago
Test name Executions per second
getElementById() 1243246.0 Ops/sec
getElementsByClassName() 807732.9 Ops/sec
getElementsByTagName() 982329.6 Ops/sec
querySelector(#id) 740481.9 Ops/sec
querySelector(.id) 965126.4 Ops/sec
querySelectorAll(#id) 309573.2 Ops/sec
querySelectorAll(.id) 372738.0 Ops/sec
jQuery(#id) 386784.7 Ops/sec
jQuery(.id) 198315.1 Ops/sec
jQuery(tag#id) 116533.5 Ops/sec
jQuery(tag.id) 121669.0 Ops/sec
jQuery + getElementById 506890.8 Ops/sec
jQuery + getElementsByClassName 176972.5 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