Remove unused CSS and Javascript

Shandy

Junior Member
Joined
Apr 7, 2017
Messages
128
Reaction score
31
Hi all, I have a Wordpress site and I'm trying to speed up my site as per page speed inshghts recommendations. To try to achieve removing unused CSS & Javascript I have installed Asset Cleanup. If I have to I will test every element Asset Cleanup suggests can be turned off on every page but I'm lazy (if I can be) and am wondering if anyone has had any success via another method?

PS. I also worry that if I turn something off and the page still looks ok on my machine it migh not load properly on the next guys machine.

Many thanks in advance
 
I haven't used it, but it says it will benefit speed and SEO.
It won't change the view on other devices.
Please share with your experience when you get success. XD
 
Hi all, I have a Wordpress site and I'm trying to speed up my site as per page speed inshghts recommendations. To try to achieve removing unused CSS & Javascript I have installed Asset Cleanup. If I have to I will test every element Asset Cleanup suggests can be turned off on every page but I'm lazy (if I can be) and am wondering if anyone has had any success via another method?

PS. I also worry that if I turn something off and the page still looks ok on my machine it migh not load properly on the next guys machine.

Many thanks in advance

what kind of pagespeed result do you get for removing unused CSS when you use wp-robots instead of asset clean up plugin?
 
I would highly suggest hiring someone to do this manually, but if you don't have a budget try with purifycss.


PS. I also worry that if I turn something off and the page still looks ok on my machine it migh not load properly on the next guys machine.

You can always test on phone or in incognito mode.
 
To try to achieve removing unused CSS & Javascript I have installed Asset Cleanup. If I have to I will test every element Asset Cleanup suggests can be turned off on every page but I'm lazy (if I can be) and am wondering if anyone has had any success via another method?
There's no simple and quick way to do this. It has to be done on a page by page basis. If you're lazy, just prioritize your most important pages (most traffic/conversions/slowest loading).

Before making any changes, make a backup. After making changes, test on different browsers, devices and screen resolutions to make sure the pages render Ok.
 
This is one of the problems when using a CMS you don't have control on every single detail vs if you code your site yourself because that way you have the freedom to do and edit every single bit. If you know what you are doing my suggestion is to get your hands dirty and do this on every page yourself. If you don't know how to do it or what to touch hire someone...
 
what kind of pagespeed result do you get for removing unused CSS when you use wp-robots instead of asset clean up plugin?
You've just started me investigating wp-robots now - I had no idea they existed - Cheers.
 
This is one of the problems when using a CMS you don't have control on every single detail vs if you code your site yourself because that way you have the freedom to do and edit every single bit. If you know what you are doing my suggestion is to get your hands dirty and do this on every page yourself. If you don't know how to do it or what to touch hire someone...
Majority of CMS users are non technical. Also you can control single details of CMS sites if you are good coder.
 
Wp-rocket will solve your issue, shortly
Ahh! Handy, I currently have the paid version of WP-ROcket - I'm guessing that they have a relevant update on the horizon?
 
Sorry, I meant to say wp-rocket
Doh! - As far as I can tell WP-Rocket allows users to minify (remove gaps) but not remove unused code but Reem Kahn (above) is suggesting they might be adding this functionality soon.
 
Doh! - As far as I can tell WP-Rocket allows users to minify (remove gaps) but not remove unused code but Reem Kahn (above) is suggesting they might be adding this functionality soon.

maybe swift performance might help.. check it out.
 
If you're lazy, use FlyingPages to defer the CSS and JS site wide. Load the JS and CSS only on user interaction. It's not a perfect solution but it's good enough if you're lazy.
 
I use Perfmatters script manager feature to remove unused CSS and JS. It removes scripts from Elementor and other plugins that are not applicable for certain posts or pages. For example, I only load Elementor scripts for pages, not posts.
 
If you're lazy, use FlyingPages to defer the CSS and JS site wide. Load the JS and CSS only on user interaction. It's not a perfect solution but it's good enough if you're lazy.

Not only if you are lazy! For example: If you have a search, why should the user load the search scripts if he don't use it. It would make sense to load the search scripts onfocus the search form or not?
 
Not only if you are lazy! For example: If you have a search, why should the user load the search scripts if he don't use it. It would make sense to load the search scripts onfocus the search form or not?

I agree. But the lazy part was in response to the OP. I didn’t mean that flying scripts is only for lazy people. Even super active people should use it. Lol.
 
Back
Top