Performance: Starts-with and ends-with selectors
MEDIUM IMPACT
These selectors affect how quickly the browser matches elements to styles during rendering.
.btn-primary { color: blue; } .active { font-weight: bold; }
[class^='btn-'] { color: blue; } [class$='-active'] { font-weight: bold; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| [attr^='value'] or [attr$='value'] | Many attribute checks per element | 0 (style only) | Low to medium (style recalculation) | [!] OK |
| .class or #id selectors | Fast direct lookup | 0 | Low | [OK] Good |