I’ve noticed that many pages with heavy javascript load certain files at the end so pages load faster, can sprockets help me do this in Rails 3? If not, what methods can I use to help performance when using scripts?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are a few things to consider here – first, the browser. Most modern browsers can asynchronously load resources, so the old trick of putting javascript at the end of the html isn’t as necessary as it once was. Have a read through this article on asynce at css-tricks: http://css-tricks.com/thinking-async/
Next, the point of the asset pipeline is to concatenate, minify and compress all the javascript and css into two files, one ‘application.js’ and one ‘application.css’.
This serves to reduce HTTP requests and means that only the first page load will take
The logic is, that with proper caching, the first load will take longer to get the monster files, but once they’ve been downloaded, the user has the js and stylesheets cached on their machine.
Have a read through the asset pipeline guide for more information about its use and benefits: http://guides.rubyonrails.org/asset_pipeline.html