Is javascript compressed by default on the server?

software development

#1

Simple question (I hope). I gather that HTTP is Gzipped by default when it leaves the server. Most browsers detect this and unzip it automatically. Is the same true for Javascript?

To clarify, I am talking about my own javascript file on my own web page. No Wordpress, no jquery, nothing clever. CUrrently it’s 400k (bad) and zips down to 40k (good). I have a bog standard beginners’ Dreamhost account with default settings. I can’t find anything in the documentation (yet) and all I can find is a comment from a post in 2013 saying it happens automatically. Can I rest easy knowing that is the case? Thanks for any help.

EDIT: further searching finally reveals what I think is the answer: yes for HTTP, no for HTTPS. Unless we enable Cloudflare, which I have now done. Fingers crossed!


#2

Note that you can manually enable compression for HTTPS by adding a DEFLATE output filter to a sites .htaccess file. Of course, one should take great care due to the security issues involved:

Full details in DH’s article on Caching and GZIP


#3

Thanks. As far as I can tell, the security issue is that an attacker could intercept and change packets, right? My site does not use PHP or any kind of authentification, and does not host anything secret. So I’m guessing that would not matter?


#4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.