Search code examples
javascriptruby-on-railsruby-on-rails-3.1coffeescriptasset-pipeline

Does the asset pipeline rails 3.1 waste cycles?


In rails 3.1, does .coffee and //= require files get processed only once or with each asset request?

For example,I have a file


//= require source/main.js.coffee
//= require source/second.js.coffee
//= require source/third.js.coffee

Ideally, the server would compile these to js ONCE, then bundle them, then create a static file. But if it happens on each asset requests,it's going to be wasting cycles repeating it??

Thanks for any guidance on this.


Solution

  • Yes, the assets will be compiled AND cached. So they won't generate additional cycles. You can also pre-compile them before you push them to production.

    Here is a good writeup: http://blog.nodeta.com/2011/06/14/rails-3-1-asset-pipeline-in-the-real-world/