C
C
CrewCut2015-10-09 13:52:12
css
CrewCut, 2015-10-09 13:52:12

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

2 answer(s)
K
Kirill Kublyakov, 2015-10-09
@CrewCut

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.

M
Marolex, 2015-10-09
@Marolex

gulp-uncss should do the trick

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question