I have a wordpress website where WP-Rocekt is already configured. But when I check the homepage’s performance in google page insight , it says remove unused CSS and use Deferred Javascript. Both of these options are already checked in WP-Rocket, how can I remove unused CSS manually?
If WP Rocket is configured correctly and you’re still seeing recommendations to remove unused CSS and defer JavaScript in Google PageSpeed Insights, you might need to take a few additional steps to address these issues manually. Here’s how you can do it:
- Identify Unused CSS: Use browser developer tools (like Chrome DevTools) to identify unused CSS. Go to the “Coverage” tab to see which styles are not being used on your homepage.
- Remove Unused CSS Manually:
- Extract the necessary CSS that your site requires. You can do this by checking the critical CSS for above-the-fold content and keeping that in your main stylesheet.
- Consider using a tool like PurgeCSS or UnCSS, which can help automate the process of removing unused styles from your CSS files.
- Inline Critical CSS: For improved loading speed, consider inlining critical CSS directly in the
<head>
of your HTML to ensure that above-the-fold content loads quickly. - Defer JavaScript: While you have the option enabled in WP Rocket, ensure that it’s applied to all relevant scripts. You can manually add the
defer
attribute to script tags in your theme or use a plugin like Asset Cleanup to manage script loading. - Test Again: After making these changes, retest your homepage in Google PageSpeed Insights to see if the recommendations are resolved.
By following these steps, you should be able to effectively remove unused CSS and defer JavaScript, improving your site’s performance.
thanks
I was having the same issue with my website but when i clicked on deferred JavaScript load, it solved the problem
If Google PageSpeed Insights flags unused CSS despite WP Rocket’s settings, use Chrome DevTools’ “Coverage” tab to identify unused styles. Remove them manually by editing your theme’s CSS file or creating a custom stylesheet, ensuring no essential styles are removed. Test changes across devices to maintain functionality and performance.