SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast sinjix_media's Avatar
    Join Date
    Mar 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Find Unused CSS on a Dynamic Site

    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
    Regards,
    Danny Michel

  2. #2
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePoint Enthusiast sinjix_media's Avatar
    Join Date
    Mar 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i hear you, but i do know that i have a HUGE amount of unused css on my site
    Regards,
    Danny Michel

  4. #4
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Enthusiast sinjix_media's Avatar
    Join Date
    Mar 2006
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks. doing it on my test site now
    Regards,
    Danny Michel


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •