04 July 2011

Google Closure Compiler And Ruby

Dan Mayer
Dan Mayer @danmayer

I have repeatedly needed to compress / minify a collection of javascript files. Which I had been doing by hand with Google’s closure compiler. I started to get annoyed with this process and went looking for a better solution. If you are using Rails, there is a great solution using Jammit asset packager library for Rails. I was not using rails, and just needed something that could write the files on demand. A bit of quick searching came up withh this post Compressing Javascript Code With Google Closure Compiler And Ruby. It basically met my needs, but needed to be modified a bit to take a collection of files and write that collection of compresses files back to disk. Here is the solution I ended up with:

    <script src="https://gist.github.com/1063584.js"> </script>    

Categories