# Compress CSS

**URL:** <https://www.ruby-forum.com/t/compress-css/85658>\
**Category:** Ruby\
**Created:** [February 15, 2007, 11:22am UTC](https://www.ruby-forum.com/t/compress-css/85658 "2007-02-15T11:22:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [February 15, 2007, 11:22am UTC](https://www.ruby-forum.com/t/compress-css/85658/1 "2007-02-15T11:22:39Z")

</div>

Hi,

Does anyone know of any script that can be used to compress css for  
deployment. Im looking for something that can be used during the build  
process rather than something you click to acheive it. Were currently  
using jsmin for javascript, something like that for css would be ideal.

cheers,

Chris

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [February 15, 2007, 11:53am UTC](https://www.ruby-forum.com/t/compress-css/85658/2 "2007-02-15T11:53:50Z")

</div>

Hi,

Have you looked at CSSTidy?

I’m thinking of using it myself, but I don’t have any experience with it

Kev

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [February 15, 2007, 12:24pm UTC](https://www.ruby-forum.com/t/compress-css/85658/3 "2007-02-15T12:24:07Z")

</div>

Hi Kevin,

Looks like an interesting project. I’ll have a look at it. I think i  
might be looking for something more script based though. Ive found a  
couple of python alternatives out there but i’d much rather use ruby

Kevin J. wrote:

> Hi,
> 
> Have you looked at CSSTidy?
> 
> I’m thinking of using it myself, but I don’t have any experience with it
> 
> Kev

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [February 15, 2007, 12:27pm UTC](https://www.ruby-forum.com/t/compress-css/85658/4 "2007-02-15T12:27:52Z")

</div>

As it’s c++ (ie native), you can add it to your rake/rant build as a  
callout with ` - then you can keep your build ruby based

Also as it’s open source, if you really wanted you could rewrite in ruby

Kev

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [February 15, 2007, 12:40pm UTC](https://www.ruby-forum.com/t/compress-css/85658/5 "2007-02-15T12:40:53Z")

</div>

Chris G. wrote:

> Does anyone know of any script that can be used to compress css for  
> deployment. Im looking for something that can be used during the build  
> process rather than something you click to acheive it. Were currently  
> using jsmin for javascript, something like that for css would be ideal.

gzip

Seriously, most browsers accept gzip compression so if you want to save  
bandwidth, the best option is to have a .gz version of each css file and  
send that if the browser supports gzip encoding. This is what I do for  
my css and javascript files:  
ReWriteCond %{HTTP:accept-encoding} gzip  
RewriteCond %{DOCUMENT\_ROOT}$1.gz -f  
RewriteRule ^(.+)$ $1.gz [passthrough,last]

Daniel

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [February 15, 2007, 12:44pm UTC](https://www.ruby-forum.com/t/compress-css/85658/6 "2007-02-15T12:44:22Z")

</div>

Came accross this plugin:

> **[Synthesis | Scott Becker](https://synthesis.sbecker.net/)**
>
> Synthesis : Scott Becker

Looks pretty cool so think i’m going with that assuming it works 🙂

Thanks for the advice.

Chris

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [February 15, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/compress-css/85658/7 "2007-02-15T16:40:26Z")

</div>

On Thu, 2007-02-15 at 20:40 +0900, Daniel DeLorme wrote:

> send that if the browser supports gzip encoding. This is what I do for  
> my css and javascript files:  
> ReWriteCond %{HTTP:accept-encoding} gzip  
> RewriteCond %{DOCUMENT\_ROOT}$1.gz -f  
> RewriteRule ^(.+)$ $1.gz [passthrough,last]

Or you can use mod\_deflate; then you don’t need to provide a gzip’d  
version. Of course, that will cost some server CPU time, so it’s a  
tradeoff…

Yours,

Tom

---

<div class="post-metadata">

**Author:** ![farfignugen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f17d59/32.png) [@farfignugen](https://www.ruby-forum.com/u/farfignugen)\
**Post date:** [February 16, 2007, 1:20pm UTC](https://www.ruby-forum.com/t/compress-css/85658/8 "2007-02-16T13:20:37Z")

</div>

> Does anyone know of any script that can be used to compress css for  
> deployment. Im looking for something that can be used during the build  
> process rather than something you click to acheive it. Were currently  
> using jsmin for javascript, something like that for css would be ideal.
> 
> cheers,

I’ve been working on a completely unrelated project but with code that  
I could fairly quickly customise to meet this requirement. I’ll try to  
knock it up over the weekend. Simply require whatever the plugin/gem  
is and call stylesheet\_include\_tag as per normal and it would  
automatically process at run-time. Need to consider how to do the  
cleanup after a file changes though.

Glenn
