I have a site which has too many unused CSS and JS files. From google developer tools I got to know how to detect unused CSS/JS files. But my problem is there is a style.css file which has 24000 lines of code and a bootstrap.css file which has 9000 lines of code. It is nearly impossible to go to each line remove styles, can anyone suggest a better way to remove those styles.
Asked
Active
Viewed 3,857 times
0
-
Well, you can google search for any online tool. Not sure how accurate it will be, but you can try https://purifycss.online/ – Gosi Sep 05 '19 at 04:12
-
Create a backup before doing all these just to be on the safe side.. – Gosi Sep 05 '19 at 04:12
1 Answers
1
Remove Unused CSS from the Stylesheet
STEP:1 Open any page of your website inside Google Chrome and then launch the Dev Tools available under File -> Tools -> Developers Tools.
STEP:2 Click the Audits tab inside Dev Tools and select the “Web Page Performance” and “Reload Page and Audit on Load” options. Now click the “Run” button to begin the CSS audit process.
STEP:3 On the results page, expand the “Remove Unused CSS Rules” group and select the CSS file(s) that are linked from your site. You may ignore the CSS files added by social plugins and widgets since you do not have control over them.
Here you will get a sorted list of all styles that are defined in the CSS file but not used anywhere on the current page.
Purvi Barot
- 608
- 3
- 9