Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36
Chrome 68
Linux
Desktop
6 years ago
Test name Executions per second
getElementById() 1050165.8 Ops/sec
getElementsByClassName() 799582.6 Ops/sec
getElementsByTagName() 752392.3 Ops/sec
querySelector(#id) 595999.0 Ops/sec
querySelector(.id) 964123.9 Ops/sec
querySelectorAll(#id) 192957.9 Ops/sec
querySelectorAll(.id) 196231.2 Ops/sec
jQuery(#id) 322834.4 Ops/sec
jQuery(.id) 147094.9 Ops/sec
jQuery(tag#id) 83641.6 Ops/sec
jQuery(tag.id) 81597.2 Ops/sec
jQuery + getElementById 623780.3 Ops/sec
jQuery + getElementsByClassName 171826.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