Search code examples
ruby-on-railsruby-on-rails-3.1ruby-on-rails-plugins

In rails 3.1 mountable engine app all the css and js are loaded for each request. won't that degrade the performance or be inefficient?


When I look at the source of any of my views generated in rails 3.1 mountable engine, I see all css and javascripts loaded. Isn't that inefficient? Wouldn't it be more efficient that I load the css and js which I need for that particular page?


Solution

  • Are you in the development environment? In production, all of your assets will be compressed and precompiled, so that only application.js and application.css are linked. This is the best way, because the js and css for your whole site is loaded into the browser cache, so that when visiting different pages, it doesn't have to make a bunch of extra server requests.