Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Chrome 73
Mac OS X 10.13.6
Desktop
5 years ago
Test name Executions per second
getElementById() 635413.8 Ops/sec
getElementsByClassName() 406365.7 Ops/sec
getElementsByTagName() 644959.4 Ops/sec
querySelector(#id) 376851.8 Ops/sec
querySelector(.id) 393591.8 Ops/sec
querySelectorAll(#id) 177841.5 Ops/sec
querySelectorAll(.id) 389910.7 Ops/sec
jQuery(#id) 433080.7 Ops/sec
jQuery(.id) 236372.2 Ops/sec
jQuery(tag#id) 134935.2 Ops/sec
jQuery(tag.id) 141639.5 Ops/sec
jQuery + getElementById 916282.7 Ops/sec
jQuery + getElementsByClassName 241492.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