Gzipping means compressing a file on your server and sending it down the wire in the compressed
.gzip format. The browser then unzips it and serves the uncompressed file on the fly. As Chris Ferdinandi says,
it reduces the size of your files by, on average, 70 percent. That’s huge!
I was recently working on an HTML file that totalled 52.2 KB including inline CSS. I wanted to check the gzipped size locally since I didn't have it up on a server yet. After some searching, I found the following command for Unix-like operating systems:
gzip -c filename.html | wc -c
As much as I hate the toxic community on Stack Overflow, I must give credit to the following page: How can I estimate the size of my gzipped script?
gzip command does the actual compression. Meanwhile:
-cflag "writes to stdout" while keeping the original files. "Writing to stdout" means that you are sending the output to the standard output device for the session, which is just your terminal session in this case.
filename.htmlpart is the name of the file you want to check.
wccommand is short for "word count". The
-cflag makes it print the byte count instead of the word count.
In short: the entire command compresses the file on the fly, without affecting the original, and prints the size of the compressed file, in bytes, to the console.
After running it for my 52.2KB file, I saw
8224 in the console. There are 1000 bytes in a kilobyte, so dividing 8224 by 1000 meant that my gzipped file size was 8.2 KB. This is exactly what I was hoping for, since under 14 KB meant I could serve the entire page in a single HTTP request. 😁