Your template engine must have a flag that you pass it to compress it, I know that Jade does this by default (I did not use EJS).
But I wouldn’t worry about removing the spaces, instead I would use the gzip library to gzip the answer down, something like gzippo is what you need.
source
share