Diagnosing the cause of slow view rendering
Solution 1:
Ok, I figured it out (at long last). Without changing any of my actual assets I am now seeing this is development:
Started GET "/" for 127.0.0.1 at 2013-03-11 23:14:33 +1300
Processing by PagesController#home as HTML
Rendered pages/home.html.erb within layouts/application (1.3ms)
It turns out the delay was being caused by config.assets.debug = true
inside of development.rb. Setting this to false
resolves the problem.
Looks like the Rails core team debated turning this off by default, but decided against the idea. In the future I'd love to see them put something in the comment section of development.rb to tip off users of the potential for significant delays.
May I suggest the following:
# Expands the lines which load the assets
# May cause significant delays in view rendering
Great, they heard me muttering and updated rails!
Solution 2:
The same issue has appeared for me in rails 4.1+. Abram's answer is only partially complete.
You can leave config.assets.debug = true
but should disable new assets verification feature
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = false
Solution with config.assets.debug
disabled only works because it compiles assets once and assets are verified once. Assets verification is where the most of the time is spent.