Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36
Chrome 87
Windows
Desktop
4 years ago
Test name Executions per second
$.hasClass 506538.8 Ops/sec
RegExp 723947.7 Ops/sec
Dry RegExp 348754.1 Ops/sec
indexOf 1679394.6 Ops/sec
classList 1998981.9 Ops/sec
hasClassString 1002785.7 Ops/sec
RegExp 2 1199511.9 Ops/sec
RegExp 3 871022.4 Ops/sec
RegExp 4 1015889.2 Ops/sec
RegExp 5 1092445.0 Ops/sec
indexOf simplest 3336766.8 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