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?
To minify CSS, try CSSNano and csso. To minify JavaScript, try UglifyJS. The Closure Compiler is also very effective. You can create a build process that uses these tools to minify and rename the development files and save them to a production directory.
Go to minifycode.com and click the CSS minifier tab. Then paste the CSS code into the input box and click the Minify CSS button. After the new minified code is generated, copy the code. Then go back to the css file of your website and replace the code with the new minified version.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With