You may also find useful to reduce the size of those files, through a process which eliminates all unneeded white spaces and comments.
Assets Packager helps you to solve these problems.
# Gemfile gem 'assets_packager' # lib/tasks/assets.rake require 'assets_packager/tasks' # shell $ rake assets:install
If you are in a
Rails context, you don't need to setup anything else,
otherwise you can specify your paths:
AssetsPackager.configure do |config| config.root_path = '/path/to/public/folder' config.file_path = '/path/to/assets.yml' end
Once you use new assets to your application, just add the to the configuration
file (look at
--- css: - application - jquery-ui js: - jquery - jquery-ui - application
Make sure to include library first, you may want to add
jquery.js before of
Assets Packager has a lot of useful
Rake tasks (
rake -T assets), the most
stylesheets. Use it as
Capistrano post deploy hook.
If you're using
Rails, in order to take advantage of bundled assets,
you should use
:cache => true option:
There are some contexts where you can't bundle assets at deploy time (like
what you can do is to reference directly to
In this way you have to bundle assets on your development machine and put them under version control.
Assets Packager was strongly inspired by the homonym plugin written by
Uladzislau Latynski for his jsmin.rb Ruby porting.
Thanks to Steve Souders for his High Performance Web Sites book.
Copyright 2011 Luca Guidi - www.lucaguidi.com - Released under MIT License