Performance: CSS Modules
MEDIUM IMPACT
CSS Modules affect how styles are loaded and scoped, impacting page load speed and style recalculation.
import styles from './Button.module.css'; function Button() { return <button className={styles.primary}>Click me</button>; }
import './styles.css'; function Button() { return <button className="btn primary">Click me</button>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Global CSS import | Low (styles applied globally) | Low (styles trigger once) | Medium (large CSS size) | [!OK] |
| CSS Modules import | Low (scoped styles) | Low (minimal style recalculation) | Low (smaller CSS size) | [OK] Good |