Sails: Uglify is too slow on already minified files

Created on 17 Feb 2016  路  11Comments  路  Source: balderdashy/sails

Hi,

Uglify is awfully slow when used on files that are already minified ; this issue is referenced there
It takes around 2 minutes to uglify a project using jquery, angular and angular-material, and therefore prevents me to push it on Heroku that has a 60 second startup limit.

So far, the solution is to never use minified version of external libs (like JQuery, Angular and so on); it takes only a few second to uglify then. Thanks to the uglify task, those files are still minified on production.

Maybe playing on the uglify task options could avoid this issue ? Or documentation should tell explicitely to avoid injecting already minified files.

grunt needs documentation performance resolved

All 11 comments

Have you thought about pre-compiling your assets and disabling the grunt hook?

So you build your LESS, JS, templates etc. Deploy with the grunt hook disabled and then when heroku spins up, it takes <1 second?

Some articles for reference
Disabling grunt hook: http://sailsjs.org/documentation/concepts/assets/disabling-grunt
Writing a custom build process: http://ash.zi.vc/sails/2016/02/08/a-better-way-of-deploying-your-sailsjs-application-to-a-production-environment/

this is the best i could get :(
{ mangle: false, sourceMap: false, screwIE8: true, compress: { unused: false, drop_console: true } }

@essuraj thanks for posting those!

@zivc sound advice.

@eric-burel we do more or less exactly what @zivc suggested for our stuff at Treeline. But that's mainly because we're also using a CDN, and also just because we have just WAY too many front-end assets right now. Re: documentation: that's a great point. If anyone has a moment to take a stab at adding a blurb about this somewhere in http://sailsjs.org/documentation/concepts/assets (e.g. a > block with a couple of sentences and a link back to this issue), I'd appreciate it.

I recommend using non minified versions of the file.
That way is much faster.
I run into the same issue and using non minified version of the files improves the performance of the build.
On the sails build they will end up minified anyway.

As @kvindasAB mentioned, this is the workaround. Switching to gulp would be better :1st_place_medal:

I recommend using non minified versions of the file.
That way is much faster.
I run into the same issue and using non minified version of the files improves the performance of the build.
On the sails build they will end up minified anyway.

@kvindasAB awesome advice

@simonmilz 馃槶 http://blog.namangoel.com/introduction-to-gulpjs | https://github.com/balderdashy/sails/issues/1461 (btw: @anyonewhohasaminutetohelp this would make a great tutorial on the site now that we have a proper tutorials section. The goal is extremely short, single page, 2-3 paragraph writeups that describe the current "definitive" way on how do things that aren't exactly core, but that come up all the time like setting up a Sails app to use gulp, etc. And then linking to other resources like that article for more info)

@mikermcneil thanks for this blog post :+1:

@mikermcneil I'm keeping a list of stuff to add to the Tutorials

Hello Guys,

I have created a small guide on how to deploy pre-built assets.

https://medium.com/@kivind/sailsjs-speeding-up-production-deployment-with-pre-built-assets-17666e9d2232

Hope it helps for the ones still bearing with this issue.

@kvindasAB thanks!

(For the record, this sort of an approach mentioned by @kvindasAB is very similar to what we cover in https://platzi.com/cursos/javascript-pro/ -- highly recommended)

Was this page helpful?
0 / 5 - 0 ratings