At Rumble Labs we're very passionate about User Interfaces and how they are designed, aesthetically, functionally and technically. For us, good design doesn't just stop at getting something to look good.
High Performance Web Sites
If you haven't already. You need to go right now and read Steve Souders blog about High Performance Web Sites maybe even pick up a copy of his book of the same name.
A lot of the principles outlined in that book are encapsulated within YSlow for Firebug (The Firefox browser extension). Webkit has an equivalent in the developer toolbar called Audits I don't think it's as good.
Rails 3.1 Asset Pipeline
The new Asset Pipeline in Rails is amazing. You can read the current work-in-progress docs by Ryan Big to get the full lowdown. Some highlights:
- We can now use CoffeeScript and SASS natively without any other processes running to compile them
- There is now multiple pre-processor support so for example, we can use erb templates to give our CSS some generated configuration.
- The best thing is this all happens out-of-the-box, everything is optimised for the developer on their local machine and in production it's fully optimised for speed.
It's very exciting that now a lot of the principles of High Performance Web Sites are built into Rails through these new conventions.
Using a CDN
For quite some time now, nearly every site we produce has had this process of using a separate static asset host.
Other than the obvious benefits of using a CDN. When used with a service like Heroku you actually dramatically increase the throughput of your web servers (dynos). As they no longer have to be bothered with serving your static assets.
Historically this has been awkward (to say the least) to do when using Heroku. With Rails 3.1 and the new Celadon Cedar stack Heroku will actually execute
bundle exec rake assets:precompile on deploy, they've also made the whole environment a lot more flexible as to what can be run. This gave us an idea.
We've open sourced asset_sync on github and released it as a gem. If you're starting afresh on Rails 3.1 you shouldn't need to do anything else. Otherwise you may want to read this article I wrote on How to Upgrade to Rails 3.1.0 and get the basics working first.
Once you're ready, to get started we need to add it to our Gemfile
rails g asset_sync:install Generate the Rake task and config file. config.action_controller.asset_host = 'https://my_bucket.s3.amazonaws.com' Ensure you have set `config.action_controller.asset_host` in **config/environments/production.rb** e.g. production: access_key_id: 'MY_ACCESS_KEY' secret_access_key: 'MY_ACCESS_SECRET' bucket: 'my_bucket' region: 'eu-west-1' existing_remote_files: 'delete'
Add your Amazon S3 configuration details to config/asset_sync.yml
And that's it! Now when you git push heroku on deploy, your assets will be precompiled and then synced up to your S3 bucket automagically.