Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

precompile slow #578

Closed
acesuares opened this issue Jun 15, 2015 · 12 comments
Closed

precompile slow #578

acesuares opened this issue Jun 15, 2015 · 12 comments

Comments

@acesuares
Copy link

Dear,

Lately, precompiling assets is terribly slow. I can't put my finger on it. I am using rails 3.2.21 and the latest gem.

Precompiling in development is fast! But in production slow.

When I precompile locally - that is to say, the precompile is local but the RAILS_ENV is production, it is also terribly slow.

Precompiling in production takes more then 20 minutes.
In application.js I have
/= require 'ckeditor/init'

Any ideas?\

@acesuares
Copy link
Author

executing "cd -- /var/www/ror/BooksBackend/releases/20150615172438 && RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile" servers: ["ror.suares.com"] [ror.suares.com] executing command command finished in 685449ms

@kyledecot
Copy link
Contributor

I'm having the same issue #573

@acesuares
Copy link
Author

with
config.assets.compress = false
config.assets.compile = false
config.assets.digest = false

-> command finished in 20.084ms

config.assets.compress = true
config.assets.compile = false
config.assets.digest = false

-> command finished in 344.198ms

config.assets.compress = false
config.assets.compile = false
config.assets.digest = true

-> command finished in 37.712ms

@acesuares
Copy link
Author

I switched to https://github.com/tsechingho/ckeditor-rails but had the same slow precompile times in production, and on top of that, ckeditor works in development but not in produdction.

#573
#579

@acesuares
Copy link
Author

#579 is now solved, but precompile is still extremely slow.

@MarcusSky
Copy link

@acesuares I think I've found the solution.
I'm assuming you're using Uglifier in production

The problem is that the CKEditor source code (also jquery and others) are already minified. So when you deploy it to Heroku, it tries to minify the already minified files, thus taking a long time.
Referencing issue: mishoo/UglifyJS#321

My solution:

# production.rb 
config.assets.js_compressor = Uglifier.new(compress: { unused: false })

References:

Let me know if that helps!

@edudepetris
Copy link

@MarcusSky I have the same problem that @acesuares and I tried your solution.
This works for me!. I reduce the precompilation time from 392.86s to 75.95s

Thanks!

@hernanvicente
Copy link

@MarcusSky Your solution works like a charm, thanks for sharing!

@tkaboris
Copy link

I copied uglifer gem into production group and changed production.rb
config.assets.js_compressor = Uglifier.new(compress: { unused: false })
But i get error on precompile
Error
at new JS_Parse_Error (/tmp/execjs20151226-10957-1dmxsmqjs:2659:11936)
at js_error (/tmp/execjs20151226-10957-1dmxsmqjs:2659:12155)
at croak (/tmp/execjs20151226-10957-1dmxsmqjs:2659:20622)
at token_error (/tmp/execjs20151226-10957-1dmxsmqjs:2659:20759)
at expect_token (/tmp/execjs20151226-10957-1dmxsmqjs:2659:20982)
at expect (/tmp/execjs20151226-10957-1dmxsmqjs:2659:21120)
at expr_list (/tmp/execjs20151226-10957-1dmxsmqjs:2659:29289)
at /tmp/execjs20151226-10957-1dmxsmqjs:2659:29559
at /tmp/execjs20151226-10957-1dmxsmqjs:2659:21493
at expr_atom (/tmp/execjs20151226-10957-1dmxsmqjs:2659:28836)new JS_Parse_Error ((execjs):2659:11936)
js_error ((execjs):2659:12155)
croak ((execjs):2659:20622)
token_error ((execjs):2659:20759)
expect_token ((execjs):2659:20982)

@edudepetris
Copy link

@tkaboris did you put require 'uglifier' in top of production.rb ?

@acesuares
Copy link
Author

This hasn't worked for me, but I need to investigate further.

@acesuares
Copy link
Author

Can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants