bundle-up icon indicating copy to clipboard operation
bundle-up copied to clipboard

Slow startup time when minify is enabled

Open aozora opened this issue 12 years ago • 8 comments

I hosted my app that use bundle-Up on nodejitsu, mut if I enable the minifyCss & minifyJs options, the app start take over 20 seconds to start, and the hosting provider than reject my app.

Looking at the code, I see that in bundle.coffee you use a lot of SYNC file operations, maybe that is the cause to the slowness... or maybe is another...

aozora avatar Sep 24 '12 16:09 aozora

Yes it is sync calls on startup in production because otherwise there is a risk that users receive assets that aren't really fully compiled yet. But yeah, 20 seconds sounds a bit too long for sure. How many css and js files do you have? Turning off minifyJS will for sure speed things up though.

Cowboy-coder avatar Sep 24 '12 17:09 Cowboy-coder

there is very little of css & js to minify... you can see on www.marcellop.com.. for now it runs only with bundle enabled but minify disabled...

aozora avatar Sep 24 '12 19:09 aozora

Hm, yeah. Not much to do about it though. Right now we are using it for a site with like 15+ .coffee files and equally amount of .stylus files and it does maybe take 4-5 seconds in startup. We are only using the minifyCss:true-option though. You could try that. UglifyJS (used by minifyJs) takes some time to process I have noticed.

Cowboy-coder avatar Sep 30 '12 16:09 Cowboy-coder

I've set all my app templates to 'minifyJs = false' in production. Would love to have it reliable and fast enough to process the JS and thus be able to enable js minification. Think it may have anything to do with the UglifyJS2 update?

~Your time, thoughts and efforts are greatly appreciated; I really like this module :)

gdibble avatar Dec 16 '12 06:12 gdibble

For me, it's fine it takes a bit of time on the first startup, the problem is that bundle up runs the compilation even when the files haven't changed since last time. So if there was an uncaught error and the process dies and restarts, it would take forever to restart. What if instead of using a hash suffix to append to the generated bundled up files, we use a timestamp. Then on every node process restart we can check if the files have been modified since last compilation before we try to compile everything again. I think that would solve our problems.

zthomas avatar Feb 10 '13 19:02 zthomas

Yeah, that's a great idea.

Cowboy-coder avatar Feb 10 '13 19:02 Cowboy-coder

I will make a change for this!

What I will do is that I will only generate the files on first startup when bundle:true is set and the following times I will only take the .css and .js files in generated/bundle and load them in directly, without ever checking the assets file.

This have been a pain-point for us as well (we're also using bundle-up in production) since it simply isn't viable to have these long start up times. This might give unexpected results for you in production, depending on how you are managing your npm modules. I will release a new version (0.4.0) to npm with this change. You will need to make sure that generated/bundle either is nuked between deploys or that the files there are up-to-date. I will also release a separate executeable that will help out to generate these bundles at build-time (using Jenkins or whatever...)

Cowboy-coder avatar Jun 11 '13 18:06 Cowboy-coder

Awesome, thanks for responding. Look forward to the update :)

zthomas avatar Jun 12 '13 14:06 zthomas