Use hasClass shorthand vs Use classList vs Use classname matchFastest: Use hasClass shorthand (3.0x faster)
7,054,838 ops/sec
6,169,006 ops/sec
2,390,823 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| Use hasClass shorthand | |
| Use classList | |
| Use classname match |
| Test name | Executions per second |
|---|---|
| ✓ Use classList | 14,553,115 Ops/sec |
| Use hasClass shorthand | 10,877,790 Ops/sec |
| Use classname match | 3,496,751 Ops/sec |