3 ms·
> Serious question: are there any tools that can scan a full website for unused code and unused CSS? We're starting to get there. JS Modules gives us static e
by madeofpalk 9y ago
> Serious question: are there any tools that can scan a full website for unused code and unused CSS?
We're starting to get there.
JS Modules gives us static exports/imports, so we can statically analytics the dependency graph and identify functions that aren't used and do tree-shaking to remove them. Rollup and Webpack2 already does this, but there's more to go.
CSS Modules creates a contract between the your CSS and what uses it. As you have to import it, and exports are static, you can understand which style files are imported where. Next step would be to understand which classes are used inside that module and strip those that remain unused. This is theoretically possible (providing you use a more 'statically safe' syntax), but tooling hasn't yet popped up to do this.