Best way to combine and minify JS / CSS on Heroku

Tom Lehman picture Tom Lehman · Dec 11, 2009 · Viewed 11.1k times · Source

First of all, according to this answer, the :cache => true option on stylesheet_link_tag and javascript_include_tag doesn't work on Heroku. Is this true? I've found :cache => true to work occasionally, but not always (weird!)

Also, what's the best solution here? Ideally it would seamlessly combine and minify all CSS / JS. Heroku Asset Packager claims to do this -- are there better options?

Answer

Greg picture Greg · Sep 10, 2010

I'm using Jammit on Heroku. Works Great. You can locally build your assets and check in to heroku. use

jammit --force

the current version 0.5.1 has issues working on heroku but you can install the fixed version from git://github.com/documentcloud/jammit.git

If you are using Rails 3, specify the below in your bundler Gemfile:

gem "jammit", :git => "git://github.com/documentcloud/jammit.git"

For Rails 2.*

config.gem "jammit", :source => "git://github.com/documentcloud/jammit.git"

Good Luck.