Javascript Question

Does it make sense to minify code used in NodeJS?

I was wondering, since Clojure Compiler and UglifyJS not only optimize code for size but also for performance (although I think size is the main priority), would my node.js app run faster if it was minified ? I know it may depend from app, but I'm asking this in general.

Answer Source

In node, the main processing cost is I/O operations, not the actual JavaScript itself. So for example:

fs.readFile(myFile, function (err, data) {

Here, the gap between calling readFile and the callback being fired will be several times longer than the length of time the callback takes. (If it's the other way round, you probably shouldn't be using node.)

So optimising the processTheFile function for speed is pointless, because you're saving a small percentage of a very very small number.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download