When you build a big application you normally use more than one CSS and JS file. The problem start here, because sometimes you have to upload several megabytes of CSS and JS files to the browser just to open a login page or something like that. This process take a lot of time and it’s not recommended.
I start searching for a solution to this problem, and I found that there are a Rails plugin that automatically compresses the CSS and JS files in just one file to use in production mode which makes the upload much faster, because the server will only send one file, and that file will be smaller since it’s compressed. In development mode you can continue to use all the uncompressed files.
In order to use the AssetPackager you need to download it from http://github.com/sbecker/asset_packager and install it.
Note: I put all my plugins in the vendor/plugins folder of my rails project since it’s a common good practice in Rails Development.
Then you run rake asset:packager:create_yml to generate the /config/asset_packages.yml file the first time.
Edit this file in order to set all the dependencies in the correct order and then create the result files with rake asset:packager:build_all.
To use the compressed files:
<%= javascript_include_merged :base %><%= stylesheet_link_merged :base %> And that’s it. ;) Sheers,Hélder Loureiro
