Asset Cleanup is a free plugin with a paid version that aims to help to remove unused css and unused js from your WordPress.
Here are some common examples of settings used in Asset Cleanup:
How to remove unused CSS or JS using Asset Cleanup
After installing Asset Cleanup, you’re prompt with welcome messages guiding you through the plugin. You can use Asset Cleanup with a compatible cache plugin but avoid enabling overlapping features that may cause issues.
Go to the wordpress pages or posts tabs and you notice a new button “Manage CSS & JS”, click on it and a new page opens with the enqueued files from that specific page.
To better assist you with removing your unwanted css or js, you can change the Assets List Layout to “grouped by size”, which will list assets by size.
Remove the unused CSS or JS enabling the “unload on this page” button. You can test any combination of removed assets using “Test Mode“.
Asset Cleanup Additional Features(Advanced)
Asset Cleanup has additional features for advanced users whiling to fine-tune their site with specific rules for removing unused CSS and JS.
It offers logic of removing css/js everywhere(all pages of the website), and removing on a specific post type, with both options able to add exceptions(where you want to keep loading it). Asset Cleanup has a note box where you can write down why you removed that asset from loading.
Asset Cleanup Test Mode
You can use Asset Cleanup “Test Mode“ feature to preview changes before they go to your live website. Enable the feature on Settings, after that, all changes will be only visible to admins that are logged in on WordPress.
Test your changes without interrupting your live website, approve them, and apply on the live website. You can also save the settings using Tools > Import/Export, in case you need more testing.
Asset Cleanup and Wp Rocket
Asset Cleanup and WP Rocket can be used together but don’t enable overlapping features to avoid issues.