Run details:
Mozilla/5.0 (Linux; Android 7.1.2) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Focus/5.2 Chrome/67.0.3396.87 Mobile Safari/537.36
Chrome Mobile 67
Android 7.1.2
Mobile
6 years ago
Test name Executions per second
getElementById() 478884.3 Ops/sec
getElementsByClassName() 311621.3 Ops/sec
getElementsByTagName() 371123.2 Ops/sec
querySelector(#id) 270121.6 Ops/sec
querySelector(.id) 341116.2 Ops/sec
querySelectorAll(#id) 140056.8 Ops/sec
querySelectorAll(.id) 156273.2 Ops/sec
jQuery(#id) 155675.0 Ops/sec
jQuery(.id) 71289.5 Ops/sec
jQuery(tag#id) 45047.0 Ops/sec
jQuery(tag.id) 46071.5 Ops/sec
jQuery + getElementById 173190.8 Ops/sec
jQuery + getElementsByClassName 58624.2 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