Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Chrome 73
Mac OS X 10.14.1
Desktop
5 years ago
Test name Executions per second
getElementById() 4096524.8 Ops/sec
getElementsByClassName() 2480699.5 Ops/sec
getElementsByTagName() 3079330.2 Ops/sec
querySelector(#id) 1945984.0 Ops/sec
querySelector(.id) 3081609.2 Ops/sec
querySelectorAll(#id) 870204.4 Ops/sec
querySelectorAll(.id) 1182765.0 Ops/sec
jQuery(#id) 1366779.4 Ops/sec
jQuery(.id) 648433.8 Ops/sec
jQuery(tag#id) 366582.7 Ops/sec
jQuery(tag.id) 371929.1 Ops/sec
jQuery + getElementById 1330107.0 Ops/sec
jQuery + getElementsByClassName 357481.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