Run details:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36
Chrome 67
Windows 8.1
Desktop
6 years ago
Test name Executions per second
getElementById() 2591018.0 Ops/sec
getElementsByClassName() 1685658.2 Ops/sec
getElementsByTagName() 2030260.6 Ops/sec
querySelector(#id) 1509670.6 Ops/sec
querySelector(.id) 1827848.4 Ops/sec
querySelectorAll(#id) 648764.9 Ops/sec
querySelectorAll(.id) 859157.6 Ops/sec
jQuery(#id) 1008144.8 Ops/sec
jQuery(.id) 445725.8 Ops/sec
jQuery(tag#id) 259018.6 Ops/sec
jQuery(tag.id) 261913.0 Ops/sec
jQuery + getElementById 1004830.2 Ops/sec
jQuery + getElementsByClassName 369588.3 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