← Back to Upcase

Assets precompiling and compressing


(charlieanna) #1

What is the difference between precompiling my assets and compressing my css, jss files? Suppose I were to precompile my assets which then are stored in my public folder, do rails then pick my assets files only from the public folder?

Or is the behavior different for development and production environment?


(Derek Prior) #2

In Rails, precompilation refers to the process of concatenating (turning several JS/CSS files into 1 JS, 1 CSS file), minifying (using something like uglifier on your JavaScript to make it basically unreadable but generally much smaller, and compressing (gzipping) those concatenated, minified files. Various pieces of this can be shut off and configured differently per environment. Rails behavior is different in development and production by default.

The Rails Asset Pipeline Guide is good. I’d suggest checking that out.


(Chris Toomey) #3

An additional note: Rails will give precedence to any file in the public folder before serving a dynamic page. This means that if you have run the rake assets:precompile step on your local machine, the assets will be present and will be used in place of the development versions.