Re: proposal: css compression via aliasing

On Mon, Sep 9, 2013 at 11:14 PM, Joey Bradshaw
<joey_bradshaw@strandedpirate.com> wrote:
> I’d like to propose a fairly simple compression specification for the next
> revision of CSS. Statistics show that the majority of users to any site will
> have an empty cache calling for a full down of assets like CSS. With the
> proliferation of vendor specific prefixes along with CSS 2.1 it is very easy
> to reach large file sizes (100+KB) causing an unnecessary bite into
> bandwidth especially for “smart” hand held devices. GZip compression and
> white-space removal goes a long way to reduce file size but a specification
> for further size reduction like below would cut sizes down dramatically.
>
> The proposal is simply to compress CSS via aliasing. Take for example this
> common CSS (124 characters):

This suggestion has come up several times - as Henrik said, it can
sometimes result in a small amount of savings over just using
compression, but very little.  The losses in readability and
authorability *far* outweigh the small gain from file size reduction.
Your stated savings of 62% are vastly overstated - the proper
comparison is between the original file compressed, and the aliased
filed compressed, where you'll see almost all of the benefit drop
away.

If we were ever going to do something like this, we'd go whole-hog -
the aliased example you give really isn't really human-readable or
writable, so there's no reason to keep up the pretense of ASCII - we
could instead define a compact binary format.  However, again I think
the actual savings from this would be pretty small, not enough to
justify the loss in readability.

Just use an uglifier to strip out whitespace and comments, and turn on
compression in your server, and you'll get plenty of savings.  CSS,
like human text, is full of massive redundancy, and so benefits well
from compression.

Finally, if you're seeing CSS file sizes in the 100Kb+ range, you're
almost certainly doing things wrong.  That kind of thing typically
suggests massive redundancy and repetition in your styles.  I suggest
learning better CSS design practices, such as OOCSS, which should
allow you to bring down the file size dramatically, helping your quest
for small files *and* greatly increasing the maintainability and
usability of your stylesheets.

~TJ

Received on Wednesday, 9 October 2013 18:38:06 UTC