Run details:
Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Chrome 69
Windows 7
Desktop
6 years ago
Test name Executions per second
getElementById() 2763205.0 Ops/sec
getElementsByClassName() 1818387.8 Ops/sec
getElementsByTagName() 2221002.2 Ops/sec
querySelector(#id) 1661311.0 Ops/sec
querySelector(.id) 2207032.5 Ops/sec
querySelectorAll(#id) 689802.9 Ops/sec
querySelectorAll(.id) 891415.4 Ops/sec
jQuery(#id) 625917.5 Ops/sec
jQuery(.id) 242231.2 Ops/sec
jQuery(tag#id) 151939.1 Ops/sec
jQuery(tag.id) 148513.4 Ops/sec
jQuery + getElementById 981833.1 Ops/sec
jQuery + getElementsByClassName 244056.7 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