Performance: Purging unused styles
This affects page load speed by reducing CSS file size and improves rendering speed by minimizing style calculations.
/* Tailwind config with purge enabled */ module.exports = { content: ['./src/**/*.{html,js,jsx,ts,tsx}'], theme: { extend: {}, }, plugins: [], };
/* Tailwind config without purge */
module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
};| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No purge (full Tailwind CSS) | Low (unaffected) | Low | High (large CSS causes slower paint) | [X] Bad |
| Purge unused styles enabled | Low (unaffected) | Low | Low (smaller CSS speeds paint) | [OK] Good |
content option lists files where Tailwind looks for class names to keep.theme controls design tokens, plugins add features, variants control responsive states, so they don't control purging.{
content: ['./src/**/*.html'],
theme: { extend: {} },
plugins: []
}content option incorrectly as ['./src/*.js'] but your classes are in HTML files inside subfolders. What problem will occur?bg-red-500 and text-xl. How can you ensure these classes are not removed?safelist option lets you list classes to always keep, even if not found in scanned files.Pass the test and this pattern moves unknown