Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
Chrome 83
Mac OS X 10.15.4
Desktop
4 years ago
Test name Executions per second
$.hasClass 3322654.8 Ops/sec
RegExp 4400665.5 Ops/sec
Dry RegExp 2299750.0 Ops/sec
indexOf 10068662.0 Ops/sec
classList 7810544.5 Ops/sec
hasClassString 3834613.0 Ops/sec
RegExp 2 4379381.5 Ops/sec
RegExp 3 4401629.5 Ops/sec
RegExp 4 4395493.0 Ops/sec
RegExp 5 4367008.5 Ops/sec
indexOf simplest 10073204.0 Ops/sec
HTML Preparation code:
Script Preparation code:
Tests:
  • $.hasClass

  • RegExp

  • Dry RegExp

  • indexOf

  • classList

  • hasClassString

  • RegExp 2

  • RegExp 3

  • RegExp 4

  • RegExp 5

  • indexOf simplest