Performance: CSS Modules
MEDIUM IMPACT
CSS Modules impact how styles are scoped and loaded, affecting CSS bundle size and render blocking during page load.
// Button.module.css
.button { padding: 1rem; background: blue; }
// Button.jsx
import styles from './Button.module.css';
<button className={styles.button}>Click</button>/* global.css */ .button { padding: 1rem; background: blue; } // In multiple components, .button class is reused globally
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Global CSS with many unused styles | Low | Low | High due to large CSS | [X] Bad |
| CSS Modules scoped per component | Low | Low | Low due to smaller CSS | [OK] Good |