Extracting only the css used in a specific page

前端 未结 15 2068
难免孤独
难免孤独 2020-12-04 06:51

Say you had a dynamically generated site that has been worked on by too many people, past and present, and you now have a collection of shared stylesheets that contain over

15条回答
  •  余生分开走
    2020-12-04 07:33

    As of Sept 2020 this question is almost 10 years old. Most of the provided solutions no longer work or the linked projects have disappeared.

    However, the question is still extremely relevant as Google now uses page speed as one of its prioritization metrics.

    After doing a bunch of research into all the links listed, I found purgecss.com. This seems to be the best option to clean up unused CSS in modern web apps/SPAs using Angular, React, Vue, etc. There's also build integration with PostCSS, Webpack, Grunt, and Gulp.

    Also, UnCSS still seems to be maintained. It's as powerful as PurgeCSS but not as integrated into build processes or single-page javascript apps.

提交回复
热议问题