CSS Minimizer program

Discussion in 'CSS' started by Silver89, Apr 8, 2010.

  1. #1
    Hey,

    Does anyone know if the following sorts of program exists..

    Say you have your whole sites CSS in one file like:

    
    .main{
    color:#000;
    border:1px solid #FF0;
    }
    
    .main2{
    color:#FFF;
    background:#000;
    border:1px solid #FF0;
    }
    
    Code (markup):
    Is there anything that can analyse that and then shorten the css down to remove multiple used code that's not needed and give you something like:

    
    .main, .main2{
    border:1px solid #FF0;
    }
    main{
    color:#000;
    }
    .main2{
    color:#FFF;
    background:#000;
    }
    
    Code (markup):
    This example doesn't really do justice to the sort of code that would be saved but you should get the idea of what I'm trying to achieve when the CSS file is 20kb in size.
     
    Silver89, Apr 8, 2010 IP
  2. pmek

    pmek Guest

    Messages:
    101
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    I actually just did a blog on this on Tuesday - you can read it here.

    Seems like it's exactly what you need.
     
    pmek, Apr 9, 2010 IP
    Silver89 likes this.
  3. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #3
    That's pretty much perfect, thanks!
     
    Silver89, Apr 9, 2010 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    I would advise against letting ANY software handle that. Not only could that screw up specificity issues, things like the cleaner will often miss that some elements are used on subpages. I've had two clients believe in that bullshit and had to re-upload their pages from scratch because of it.

    It's like most of the automated tools, if the page is written properly in the first damned place they do more harm than good.
     
    deathshadow, Apr 9, 2010 IP
  5. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #5
    Well mine are all written correct just a couple of instances where the css is used over and this solves that. I'd never replace my css with this but creating a main-min and seeing if it all functions correctly isn't going to harm anything.
     
    Silver89, Apr 9, 2010 IP