Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any benefit to minifying source code that is read only by Node? [duplicate]

In a NodeJS application, is there any benefit to using minified source code server-side?

The only benefit I could come up with, is that the smaller JS files would probably be loaded slightly faster from disk. But that seems negligible given that it would only impact startup time.

So, would there be any reason to process our source through uglify or closure compiler before deploying it to our production servers?

like image 740
Oliver Salzburg Avatar asked Feb 14 '14 23:02

Oliver Salzburg


1 Answers

The point of minification is reducing bandwith (smaller file = less bytes). Since you're not sending your sever-side code to your client, there's no reason to reduce it. True, reading the file from disk will be a tiny bit faster, but if startup time is your bottleneck, you've got some bigger problems.

Having said that, closure compiler isn't only a minifier: it attempts to be a javascript compiler, trying speed up your code. The different JITs might also like your "compiled" code better, especially in function inlining. Having said that, the speed difference will likely be negligible.

In conclusion: No, but you might enjoy reaping the side-effects. I don't know of any tests, so you could be a pioneer in the field. Benchmark your unminified program over some time, then benchmark the minified version.

like image 117
Zirak Avatar answered Sep 23 '22 00:09

Zirak