sprockets-rails icon indicating copy to clipboard operation
sprockets-rails copied to clipboard

Precompiling on page load in development

Open neyp opened this issue 7 years ago • 1 comments

I'm using Rails 5.1.4, sprockets 3.7.1 and sprockets-rails 3.2.1. When I start the development server and visit a url for the first time, precompiling is triggered hugely slowing down page load. This wasn't happening with Rails 4 and an older version of Sprockets.

neyp avatar Jan 09 '18 14:01 neyp

Caused by https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/railtie.rb#L34-L52. The asset_precompiled? is called under development environment and the precompiled_assets is the time consuming one.

Since sprockets v3, there is a raise_unless_precompiled_asset call for each asset_path call to check if the asset precompiled. Sprockets-rails v2 does not perform such checks.

https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/rails/helper.rb#L78 this line controls to skip the asset_precompiled? check. However the options[:debug] is not presented true under development environment and seems useless. Setting it true will avoid the precompiling.

I am wondering if the debug option should be passed true for development environment?

onyxblade avatar Feb 27 '18 05:02 onyxblade