yui_compressor_fu

Please welcome a new thingie I just released – yui_compressor_fu.

Point

yui_compressor_fu delicately minifies all your assets (linked with javascript_include_tag, stylesheet_link_tag helpers) with YUI Compressor. It abides Rails caching rules. All you have to do is install the plugin, and minifying will automatically kick-in when rails performs its normal caching routines.

Tale

Today I was having my usual cup of Earl Grey with lemon while trying to find some JS/CSS minifying solution. Nowadays Rails provides built-in concatenation and caching, but not compression. I wanted to find something that transparently adds some minifying to the mix. Well, not so fast.

After flipping through quite a few choices, I wasn’t impressed at all. Available plugins either require too much configuration (why do I have to list all my assets again, asset_packager?) or they use inferior compression algorithms (Packer/MinJS). According to my research (don’t quote me) – YUI Compressor kicks some major ass. A few minutes of fruitless digging later I decided to make this plugin instead.

Feel free to try it out and let me know of any issues you encounter.

8 responses to “yui_compressor_fu”

  1. Double Shot #464 « A Fresh Cup

    [...] yui_compressor_fu – Automatic minimization of CSS/JavaScript for Rails applications. [...]

  2. Luke Francl

    This is excellent. I don’t like that existing solutions like asset packager force you to keep a separate list of your JavaScript and CSS files outside of your code.

  3. Joe Van Dyk

    I wrote this exact same plugin a few months ago: http://github.com/joevandyk/fixie_shrinker/tree/master

    Except that my plugin compresses the CSS and JS whenever those files change in development mode, so you’re ensured that your JS and CSS will compress correctly.

  4. Philip

    Hi, I’ve spent time today looking into this whole YUICompressor vs other approaches. Glad to find your link before I start doing my own customized Capistrano tasks to help integrating YUICompressor with my deployed Rails app.

    Two thoughts: 1. Glad to see that you include the latest YUICompressor jar in the plugin! Now… if only this plugin can help install Java on the deployment machine. xD It’s such a pain to install Java on Linux. (I know this is a wishful thinking. :)

    1. On this jar-inclusion thing: Perhaps you would like to include a Capistrano or Rake task to help one grab and update the jar whenever/if it releases a new version? That way, you won’t have to update this great plugin just to catch up if/when the time comes.

    Thanks for sharing this neat, little plugin! If only YUICompressor has a Ruby version, I am sure this would become a very popular integration choice and plugin.

Leave a Reply