Remove unused CSS like this

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Reaction score
13
Run Dust-Me Selectors (addon for Firefox) on the pages you'd like to run through
Export the CSV file somewhere
Download JClaim (it's a Java chat client) - If you run the jnlp file you download from sourceforge it would install the application.
When you open it up it's going to ask you to connect to a chat server, just close this box you don't need to do anything
Click on "File" and then go to "Handy Tools" where you will see "Clean CSS"
On there you will select your original CSS file, then the CSV file you exported from Dust-Me
Click "go" and in the output box it will give you a stripped down list of all your used CSS
Open up a new CSS file and copy/paste it in there and check for any obvious mistakes (I had ",{" in there where it removed chained CSS statements)

Dropped my CSS filesize from 152kb to 26kb unminified... and was exactly what I was looking for a few months ago.

So hopefully some sod would find this & PayPal me a donation for giving you this valuable information...
 
IMO all you need is Google Page Speed (and firebug)
and it does CSS, html and javascript minifying
 
IMO all you need is Google Page Speed (and firebug)
and it does CSS, html and javascript minifying

IMO you totally don't understand what I just said huh? Well let me dumb it down for you:

If you have 5000 styles in 1 style sheet
And you use 239 of those styles in your page

No amount of minifying will get your file size down. The only way to do it is to get rid of the styles you don't use. PageSpeed/YSlow and Dust-Me only gives you an indication of which styles are not used, but they don't help you wade through all of your **** at once and remove them in the first place.

(NB, this is before minifying anything)

So essentially I have ONLY the styles I NEED and can now minify the CSS to even get a SMALLER file if I want to. This is helpful for people who use designers who don't clean their **** because they're too ****ing lazy so they just add-on to styles all the time
 
If you say so

I did.

So next time please see the difference in removing unused CSS & how to and minifying it and "how to". I use PageSpeed to do all that **** for me, the only thing it can't do is give me a copy of the CSS without the selectors that went unused... which I shown people now how to do.

If you don't need it because you're happy minifying unused code and plonking it in your website, be my guest. I'm more of a control freak when it comes to my client's sites
 
I can appreciate the need to remove loads of unwanted/unused styles but surely you don't use a new style sheet per page so many styles which will be needed on other pages will be stripped and there will be errors when those pages are viewed? It may be bad practice but I think 90% of our site's styles are in a single style sheet so this would never work in most cases for me.
 
It's helpful if you reuse styles sheets for all your websites and build upon old style sheets. Our XHTML guys, however, have framework style sheets and build upon this core with every site they do so each of the sites never have any styles that aren't used.

152 kB is pretty large for a style sheet, the total size of the style sheets used in our biggest government site is only 28 kB uncompressed including comments and white space.
 
It's helpful if you reuse styles sheets for all your websites and build upon old style sheets. Our XHTML guys, however, have framework style sheets and build upon this core with every site they do so each of the sites never have any styles that aren't used.

152 kB is pretty large for a style sheet, the total size of the style sheets used in our biggest government site is only 28 kB uncompressed including comments and white space.

Just looked, our style sheet is 13Kb un-minified, 152Kb does sound very big
 
Thanks, Acid.
Run Dust-Me Selectors (addon for Firefox) on the pages you'd like to run through
Export the CSV file somewhere
Download JClaim (it's a Java chat client) - If you run the jnlp file you download from sourceforge it would install the application.
When you open it up it's going to ask you to connect to a chat server, just close this box you don't need to do anything
Click on "File" and then go to "Handy Tools" where you will see "Clean CSS"
On there you will select your original CSS file, then the CSV file you exported from Dust-Me
Click "go" and in the output box it will give you a stripped down list of all your used CSS
Open up a new CSS file and copy/paste it in there and check for any obvious mistakes (I had ",{" in there where it removed chained CSS statements)

Dropped my CSS filesize from 152kb to 26kb unminified... and was exactly what I was looking for a few months ago.

So hopefully some sod would find this & PayPal me a donation for giving you this valuable information...
 
I can appreciate the need to remove loads of unwanted/unused styles but surely you don't use a new style sheet per page so many styles which will be needed on other pages will be stripped and there will be errors when those pages are viewed? It may be bad practice but I think 90% of our site's styles are in a single style sheet so this would never work in most cases for me.

That's the point of running Dust-Me, it goes through your site to check which styles go unused because (obviously) it will be a bad idea removing something you're not using on that specific page... and I've had designers give me this **** before, where they'll cutup a design, something will change or there is some kind of issue they're having with the cutup, and then instead of removing everything/using a new stylesheet, they just add onto the stylesheet.

I have one guy constantly give me a CSS file (20-60kb big) and running Dust-Me/PageSpeed etc shows me that almost 70% of the styles go unused throughout the site... I'm not sure about you but i'd rather have my file size minimal to gain some nice speed on the site than run around adding **** I never needed in the first place making my site bloated in the end.
 
That's the point of running Dust-Me, it goes through your site to check which styles go unused because (obviously) it will be a bad idea removing something you're not using on that specific page... and I've had designers give me this **** before, where they'll cutup a design, something will change or there is some kind of issue they're having with the cutup, and then instead of removing everything/using a new stylesheet, they just add onto the stylesheet.

I have one guy constantly give me a CSS file (20-60kb big) and running Dust-Me/PageSpeed etc shows me that almost 70% of the styles go unused throughout the site... I'm not sure about you but i'd rather have my file size minimal to gain some nice speed on the site than run around adding **** I never needed in the first place making my site bloated in the end.

Never used Dust-Me before, if that is what it does then is makes perfect sense
 
Never used Dust-Me before, if that is what it does then is makes perfect sense

Sorry I'm confused. Then why put in your 2cents?

I'm growing tired of the internet... yes no go ahead doing whatever you guys want. I'm going to **** off and shut the **** up because apparently I know nothing right? Maybe that one **** can comment on this thread and go "I knew I was right, you don't know what you're talking about! yay! I love teh win"
 
Sorry I'm confused. Then why put in your 2cents?

I'm growing tired of the internet... yes no go ahead doing whatever you guys want. I'm going to **** off and shut the **** up because apparently I know nothing right? Maybe that one **** can comment on this thread and go "I knew I was right, you don't know what you're talking about! yay! I love teh win"

Not to derail the thread any further, but this is exactly why I'm choosy about where I post. For instance, I avoid the philosophy forum entirely. Anonymity gives people great courage who would otherwise be careful with their words. It's something that has been debated at length on other sites, and I tend to agree with. It's also the reason I try to use one username on all forums - it forces me to keep it real knowing that the info can be compiled. (Privacy on the web is another matter entirely.)
 
I'm with Raithlin on this - this is a discussion forum and the point is to add your 2 cents if you feel like it. If you don't want comments, message somebody directly.
 
Sorry I'm confused. Then why put in your 2cents?

I'm growing tired of the internet... yes no go ahead doing whatever you guys want. I'm going to **** off and shut the **** up because apparently I know nothing right? Maybe that one **** can comment on this thread and go "I knew I was right, you don't know what you're talking about! yay! I love teh win"

:erm:

Whatacock.
 
IMO you totally don't understand what I just said huh? Well let me dumb it down for you:

Great, so you insult someone into the ground and then you expect them to take you seriously afterwards?

I'm growing tired of the internet... yes no go ahead doing whatever you guys want. I'm going to **** off and shut the **** up because apparently I know nothing right? Maybe that one **** can comment on this thread and go "I knew I was right, you don't know what you're talking about! yay! I love teh win"

You just have to read a few of your replies to threads in general to quickly realise that you clearly have a chip on your shoulder. You're very aggressive for no reason and you have no problem insulting others on the forum, you get personal very quickly and it's annoying. Stop being so sensitive. You started a thread about CSS cleanup so the idea is to welcome other people's opinions on the matter. The fact that they have a different opinion or disagree with you is not the end of the world and certainly not reason for you to throw one of your numerous little MyBB tantrums. Whoever visits this thread tomorrow will perhaps get 3 different approaches to cleaning up CSS and everyone wins.

You make it quite unpleasant with your constant insults and therefore derail some threads automatically. Lock yourself in a room and scream for 2 hours and then look in a mirror and tell yourself yourself how wonderful you are. That way we don't have to hear about it.
 
Great, so you insult someone into the ground and then you expect them to take you seriously afterwards?



You just have to read a few of your replies to threads in general to quickly realise that you clearly have a chip on your shoulder. You're very aggressive for no reason and you have no problem insulting others on the forum, you get personal very quickly and it's annoying. Stop being so sensitive. You started a thread about CSS cleanup so the idea is to welcome other people's opinions on the matter. The fact that they have a different opinion or disagree with you is not the end of the world and certainly not reason for you to throw one of your numerous little MyBB tantrums. Whoever visits this thread tomorrow will perhaps get 3 different approaches to cleaning up CSS and everyone wins.

You make it quite unpleasant with your constant insults and therefore derail some threads automatically. Lock yourself in a room and scream for 2 hours and then look in a mirror and tell yourself yourself how wonderful you are. That way we don't have to hear about it.


I kinda agree with you, his posts and threads seem to have a holier than thou attitude to them.
 
Top
Sign up to the MyBroadband newsletter
X