Each css / js you load causes your site to load slower ! You can speed things
up exponentially by simply combining all your css/js files into one file each.
Bundle_fu makes it easy to do. It’s as easy as 1, 2 !
Install this plugin
script/plugin install git://github.com/kares/bundle-fu.git
Put the following around your stylesheets/javascripts (note it works with any
method of including assets!):
<% bundle do %>
...
<%= javascript_include_tag "prototype" %>
<%= stylesheet_link_tag "basic.css" %>
<%= calendar_date_select_includes params[:style] %>
<script src="javascripts/application.js" type="text/javascript"></script>
...
<% end %>
That’s it!
The <% bundle %>
method accepts several options :
:js_path
defaults to"/javascripts/cache"
:css_path
defaults to"/stylesheets/cache"
:name
the bundle name set it if you have multiple bundle blocks:bypass
if You want to skip the asset bundling, if its a Proc
or symbol it will call/send it and use it’s outcome:packr_options
if Packr is
available (defined) it will use it for packing javascript files and pass the
given options to it.
This fork was created mainly to add support for asset id (timestamping) in CSS
url links. Bundle-fu by default rewrites (relative) CSS urls, it’s very useful
if these rewrites use the rails provided asset tag helpers, thus enjoying asset
cache busting with far future headers. This is exactly what this version does !
#header {
background-image: url(../images/header-bg.png) no-repeat scroll;
}
#footer .button {
background-image: url("./images/button-bg.gif");
}
#header {
background-image: url(/images/header-bg.png?1275245642) no-repeat scroll;
}
#footer .button {
background-image: url(/stylesheets/images/button-bg.gif?1275842817);
}