Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove unused CSS on the Fly?

Tags:

css

Having a problem at the moment that many of my pages load [using GooglePageSpeed] and seem to load a lot of unused CSS.

If I try and split the CSS - then I get the error that "too many CSS files". I am wondering whether there are any jquery plugins [or other] that are able to RENDER only the CSS for the page that is being loaded and ignore the rest ?

It's sort of like a dynamic CSS interchanger ? Would really help ....

like image 612
Tom Avatar asked Dec 17 '22 02:12

Tom


2 Answers

Unless you are sending hundreds of kb of css then it shouldn't really matter.

A dynamic CSS changer would destroy the caching ability of the browser resulting in higher transfers.

like image 193
graham.reeds Avatar answered May 22 '23 10:05

graham.reeds


I would suggest you to go for Dust-Me Selectors (addon of firefox) to check unused css and delete it for specific pages. Note this is not something allowing you to delete on-the-fly though.

alt text

like image 43
Sarfraz Avatar answered May 22 '23 10:05

Sarfraz