sinjix_media — 2011-05-12T04:27:10-04:00 — #1
Looking to find, remove unused CSS on a dynamic site.
Possible an FF 4 extension.
Tried Helium and DustMeSelectors doesnt work on FF4 and I dont think it works on dynamic sites anyway
samanime — 2011-05-12T04:29:23-04:00 — #2
It would be very difficult to create such a plugin. You'd have to basically look at every single page in the site and hunt for unused CSS.
Even then, it's not guaranteed you aren't getting rid of something that is supposed to be used, because it could be part of an error system, CSS elements/classes for a CMS, etc.
Unless you suspect a huge amount of unused CSS, I'd say leave it. The risk of an extra kilobyte or two is worth not breaking your site in some unforeseen way. Of course, it's better to keep track of this when developing and make sure none gets left in.
sinjix_media — 2011-05-12T04:39:49-04:00 — #3
i hear you, but i do know that i have a HUGE amount of unused css on my site
samanime — 2011-05-12T04:58:57-04:00 — #4
In that case, you may want to take a slightly trial-and-error approach.
You're running a Wordpress site, so that means you have a finite number of template files.
Go through those and pull out all the elements, classes, and IDs that you use in your templates. You could use a text editor to search for "<", "class", and "id" to find your targets.
Then, go through your CSS and look for CSS that isn't in that list. Remove it, run through a handful of pages and make sure you didn't accidentally break anything. (You could try commenting it out with /* */ around the block, then testing, and remove everything at the end).
If you get a steady supply of traffic, I highly recommend doing this on a local/test server, as you'll probably break stuff.
However, looking at your site, it looks like there is only 40kb of CSS (unless you somehow have control over the ones on the fbcdn ). That is a bunch, but unless you think you're going to be able to reduce it by about 50% or more, I honestly wouldn't risk trying to clean it up in one go. Over time you could slowly find bits and pieces that aren't used and pull them out. You can probably find better areas to direct that effort.
Nice site, btw. Very clean.
sinjix_media — 2011-05-12T05:04:04-04:00 — #5
thanks. doing it on my test site now