Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need a css minifier in ruby

I am looking for a css minifier that I could use in rails apps (not gziper) which doesn't need a command line YUI compressor instalation. I am working on a content mangament software where the css is pasted into a textarea and then I want to minify then gzip and send it to amazon. So those solutions are not OK which use some command line preprocessing... Any ideas?

Online minifier services are also welcome.

like image 626
Boti Avatar asked Sep 09 '11 19:09

Boti


3 Answers

You could also try SASS with :syntax => :scss, :style => :compressed.

like image 69
Luchs Avatar answered Oct 07 '22 01:10

Luchs


I think I have found my gem:

'ruby-yui-compressor'

All I need to do:

gem "yui-compressor", "~> 0.9.6", :require => "yui/compressor"
....
compressor = YUI::CssCompressor.new
compressor.compress 'body {line-height: 1}            \ntable {border-collapse: collapse;    border-spacing: 0}'

=> "body{line-height:1}\\ntable{border-collapse:collapse;border-spacing:0}" 
like image 21
Boti Avatar answered Oct 07 '22 03:10

Boti


How about Juicer?

like image 23
Kudu Avatar answered Oct 07 '22 03:10

Kudu