Run details:
Mozilla/5.0 (Linux; Android 8.1.0; Moto G (5)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Mobile Safari/537.36
Chrome Mobile 73
Android 8.1.0
Mobile
5 years ago
Test name Executions per second
getElementById() 369368.3 Ops/sec
getElementsByClassName() 249927.3 Ops/sec
getElementsByTagName() 276947.7 Ops/sec
querySelector(#id) 193455.6 Ops/sec
querySelector(.id) 269673.6 Ops/sec
querySelectorAll(#id) 128608.8 Ops/sec
querySelectorAll(.id) 151809.5 Ops/sec
jQuery(#id) 135116.0 Ops/sec
jQuery(.id) 88250.0 Ops/sec
jQuery(tag#id) 51633.1 Ops/sec
jQuery(tag.id) 53413.2 Ops/sec
jQuery + getElementById 166260.6 Ops/sec
jQuery + getElementsByClassName 66695.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