Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Chrome 67
Mac OS X 10.13.5
Desktop
6 years ago
Test name Executions per second
getElementById() 3704657.8 Ops/sec
getElementsByClassName() 2414127.8 Ops/sec
getElementsByTagName() 2894321.2 Ops/sec
querySelector(#id) 2208136.8 Ops/sec
querySelector(.id) 3086448.2 Ops/sec
querySelectorAll(#id) 970174.4 Ops/sec
querySelectorAll(.id) 1241429.4 Ops/sec
jQuery(#id) 1320860.4 Ops/sec
jQuery(.id) 650807.3 Ops/sec
jQuery(tag#id) 367091.1 Ops/sec
jQuery(tag.id) 381313.8 Ops/sec
jQuery + getElementById 1334157.6 Ops/sec
jQuery + getElementsByClassName 484274.4 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