Reputation: 1855
This question isn't how to concat & minify js code - it's when, and to what should it be done to. (Perhaps a result of the JS invasion into server from client)
From what I understand, concatenating code is a technique that arose as a means to reduce number of script requests. As such, this task should be run on JS that will be requested and run in the client - concatenating my files running on Node won't be of any use.
On the other hand, minifying arose as a technique to reduce the total size of a script without impacting functionality, thus reducing the number of bits transferred in a request. Again, this technique seems best applied to code that intends to be transferred to the client.
Do I get any performance gain from performing these tasks on my JS running on my server?
Upvotes: 0
Views: 237
Reputation: 146084
Concatenating several CommonJS modules is not possible in node.js, crazy hacks aside. Minifying is (questionably, IMHO) beneficial only for network transfers, and since nearly all code executed in node.js processes is loaded from the local filesystem, loading minified CommonJS modules into node is essentially unheard of.
Upvotes: 5