Answer the question
In order to leave comments, you need to log in
How can I remove unused css styles from a file?
There is a css file with 20k lines. At the same time, 30% of styles are needed only for one page, another 20% for another. The others on these pages are not used, but are used on the rest.
In my mind, for these two pages it would be necessary to make separate files, but did not. The file itself is not very logical and is not logically divided into sections.
Actually a question - the browser after all understands what styles it needs for display, what is not present. Is it possible to somehow get a squeeze from the file, where there will be only styles applicable to the elements on this page?
Answer the question
In order to leave comments, you need to log in
As already advised, gulp-uncss should help. In chrome, in the developer tools on the "Audit" tab, run the actual audit and the results will include, among other things, a list of unused selectors on the page and a percentage of all css.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question