ruby-on-railsherokuasset-management

Asset managing with Rails 3 (on Heroku) (Jammit, AssetHat, Rack PageSpeed)


I am interested in the pros and cons of the different tools for managing assets in Rails 3.0.x (especially on Heroku).

There are already some older questions regarding this topic, but in the meanwhile there are some new tools available.

I am especially interested in these tools:

Jammit seems to can do everything that AssetHat can do and is also longer available. So where does AssetHat fit in?

Rack PageSpeed seems to do everything on the fly by directly working on the server response. Did you experience any performance issues by doing that? Would you recommend it over the other two solutions?


Solution

  • Hey there, I'm the author of AssetHat. Minification and concatenation are among the easiest performance boosts to implement; these features are common to Jammit, AssetHat, and rack-pagespeed. Rails has supported concatenation for a long time now (though it's done at runtime, rather than during deployment), and it's no surprise that Rails 3.1 supports both minification and concatenation during deployment.

    The remaining features are what make each of these asset managers interesting. For example, Jammit is useful if you want to embed images and font files directly into your stylesheets. rack-pagespeed is also handy if you want to keep all your optimizations in a completely separate layer.

    Inlining assets into CSS is great for static pages where stylesheets change infrequently. However, if your site is under active development, and the stylesheet changes even a tiny bit, the user's browser has to re-download the whole thing—including inline images and fonts that probably didn't change. It depends on the nature of your project.

    If your assets are too big to inline or concatenate, AssetHat helps optimize for CDNs and parallel loading:

    By using CDNs like Google's or Amazon's, your users can load more assets in parallel (because there are more hostnames), enjoy greater speed, and sometimes, not even need to download assets at all (e.g., if they already loaded Google's copy of jQuery via someone else's website).

    I've used AssetHat on Heroku by setting my deploy script to simply run rake asset_hat:minify (to minify and concatenate CSS/JS), commit those changes to my repository, then do the actual deployment.

    In case you haven't seen these already, you might be interested in:

    If you need help setting it up, or have any other questions, feel free to message me on GitHub (rondevera) or Twitter (@ronalddevera).