Compress HTML with Node, Express & EJS?

I use EJS with Node and Express. The HTML created by my views is large and full of unnecessary spaces. Is there an option or middleware that I can use in production that compresses HTML?

eg.

<!doctype html>
<html><head><title>...</title>....</html>
+5
source share
1 answer

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.

+1
source

All Articles