config.assets.compile=true in Rails production, why not?

The default Rails app installed by rails new has config.assets.compile = false in production.

And the ordinary way to do things is to run rake assets:precompile before deploying your app, to make sure all asset pipeline assets are compiled.

So what happens if I set config.assets.compile = true in production?

I wont’ need to run precompile anymore. What I believe will happen is the first time an asset is requested, it will be compiled. This will be a performance hit that first time (and it means you generally need a js runtime in production to do it). But other than these downsides, after the asset was lazily compiled, I think all subsequent access to that asset will have no performance hit, the app’s performance will be exactly the same as with precompiled assets after this initial first-hit lazy compilation. is this true?

Is there anything I’m missing? Any other reasons not to set config.assets.compile = true in production? If I’ve got a JS runtime in production, and am willing to take the tradeoff of degraded performance for the first access of an asset, in return for not having to run precompile, does this make sense?

7 Answers
7

Leave a Comment