My application.js file looks like this:
//= require jquery
//= require jquery_ujs
//= require rails.validations
//= require_tree .
My development site has this in the source:
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/rails.validations.js?body=1" type="text/javascript"></script>
<script src="/assets/home.js?body=1" type="text/javascript"></script>
<script src="/assets/industries.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery-1.7.1.min.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.ba-hashchange-v1.3.min.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.flexslider-v1.8.min.js?body=1" type="text/javascript"></script>
<script src="/assets/main-r6.js?body=1" type="text/javascript"></script>
<script src="/assets/welcome.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>
But my production looks like this:
<script src="/assets/application-b5f7c629f9622da89d5cc703e459e6c3.js" type="text/javascript"></script>
My config/environments/development.rb has this:
config.assets.compress = false
My config/environments/production.rb has this:
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true
Thoughts?
Both environments are including all the javascript. By default in production mode the rails asset pipeline combines/minifies your javascript (and css), this reduces the amount of requests the browser/client needs to make to the server.
There’s a detailed explanation of the asset pipeline in the rails guide:
http://guides.rubyonrails.org/asset_pipeline.html