Rails Javascript and CSS Compression
Posted: July 30th, 2009 | Author: mindtonic | Filed under: Development, Rails Plugins, Ruby On Rails | Tags: css, javascript, rails | No Comments »To speed up site loading, there are two great plugins for “compressing” your stylesheets and javascript.
The first is bundle-fu. This plugin does not actually compress the files, but rather combines all of the individual documents into one before shipping it out to the client browser.
$ script/plugin install git://github.com/timcharper/bundle-fu.git
And then you simply wrap your sheet and script calls in the bundle method:
<% bundle do %>
...
<%= javascript_include_tag "prototype" %>
<%= stylesheet_link_tag "basic.css" %>
<%= calendar_date_select_includes "red" %>
...
<% end %>
The Second plugin, which actually does compress all of your files, is sbecker’s asset_packager. This one is a lot more involved, so check out the github site for more information.
Leave a Reply