3

I have a Rails 3.2 app running on Heroku, and it uses CKEditor. Now, CKEditor is a pretty large collection of files and folders, and is probably the biggest contributor to the time it takes to precompile assets. A regular push to Heroku takes well over a minute on the assets:precompile step.

So I now precompile locally, and only when I've made edits, before I push to Heroku, to shorten deploy times. However, my poor old Windows laptop easily breaks 15 minutes for rake assets:precompile. This makes it a huge pain to make minor edits or additions to js or css files.

I do have config.assets.initialize_on_precompile = false as required by Heroku docs. But I'm pretty sure the real time hog is compression, i.e. Uglifier.

Does anyone have a suggestion to how I can remedy this? Am I simply doing it wrong? Is there a way to only compile changed files? Could/should I move CKEditor directly to the public dir to avoid precompiling?

Stylpe
  • 612
  • 1
  • 7
  • 16
  • Do you use the nondigest files at all? – James Mar 03 '12 at 16:58
  • Sorry, not sure what you mean by nondigest files? – Stylpe Mar 04 '12 at 18:08
  • Digest files are the generated files with md5 hashes baked into their filenames. The precompile task creates digest and nondigest versions of each asset if you have digest set to true in your config. Using the rails helpers such as `image_tag` and the scss helpers such as `image-url` will automatically generate the correct digest urls. That leaves the nondigest files which are also generated, are you using those in your app at all? Basically what I'm asking is if those files were deleted, would your app still function correctly? – James Mar 04 '12 at 19:02
  • No. My app code only uses the helpers, so digest asset names are used, but CKEditor dynamically includes plugin .js files, and from the network monitor in the Chrome inspect frame it shows both digest and non-digest files being requested on pages with the editor. – Stylpe Mar 04 '12 at 19:30
  • You can override the precompile rake task so that it doesn't generate the nondigest files (roughly 50% reduction in time) but it looks like it wouldn't work with the way your app is setup. – James Mar 04 '12 at 20:02
  • Have a look at http://stackoverflow.com/questions/9739654/rake-assetsprecompile-taking-extremely-long-to-complete/9745386#9745386 – bradgonesurfing Mar 16 '12 at 22:56

1 Answers1

4

You can try to load the assets only on the changed files which would speed up compiling process by a huge margin. You can easily do so using turbo-sprockets-gem.

https://github.com/ndbroadbent/turbo-sprockets-rails3

The documentation is pretty straight forward. Hope this helps.

Thresh
  • 470
  • 6
  • 18
  • 1
    Hey, thanks for answering a two year old question, I guess! I don't know if this question still is as relevant as it was back then, but I'll go ahead and accept this answer anyway :P – Stylpe Feb 13 '14 at 18:56
  • Thank you :) much appreciated, I answered because I faced the problem as well and didn't find an answer to it so I thought it would be useful to anyone searching. – Thresh Feb 17 '14 at 13:46