Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
Chrome 72
Linux
Desktop
5 years ago
Test name Executions per second
getElementById() 2682907.0 Ops/sec
getElementsByClassName() 1627928.2 Ops/sec
getElementsByTagName() 2007763.1 Ops/sec
querySelector(#id) 1499228.2 Ops/sec
querySelector(.id) 2075345.4 Ops/sec
querySelectorAll(#id) 524731.2 Ops/sec
querySelectorAll(.id) 591272.9 Ops/sec
jQuery(#id) 747136.8 Ops/sec
jQuery(.id) 401302.0 Ops/sec
jQuery(tag#id) 219481.9 Ops/sec
jQuery(tag.id) 239859.8 Ops/sec
jQuery + getElementById 965208.4 Ops/sec
jQuery + getElementsByClassName 347744.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