foobar.css.gz rather than
How exactly does this whole compression of JS and CSS files work? Why is it useful? Are there any downsides to this? How does one accomplish this?
The CPU time needed to decompress the HTTP response tends to be much shorter than the time it would take to transfer the extra bytes over the network.
Most systems using HTTP compression do it on the fly and do not require that publishers store compressed
The specifics for accomplishing it depends on the web server you are using. Since you tagged this with two different servers, it is hard to say how to solve it in your case. The manual for your server should explain it though.
You’re right – it is a lower file size, and the browser does need to decompress it. But the lower file size while getting from the server to the browser is the important part (it saves both the server and the browser bandwidth, which usually costs money).
Decompressing such small files tends to be really fast, too, faster than downloading the extra data.
How you do it depends on your sevrer, I know for apache you can use mod_deflate, and you just have to set that up on the server and it compresses the files automatically as they’re sent, you don’t need to change any of your web pages or anything.