Why is gzipped html file rendered without JS and CSS?
I have a html file saved in gzip format. The browser displays the html file, but no javascript and CSS. Non-zip html files in the same directory render correctly. Also, I saved the source from a compressed html file and it was reopened using JS and CSS.
What is the difference between the rendered zip-html that will prevent it from picking up JS and CSS?
a source to share
The main problem is that you cannot just serve a gzip file where the browser expects CSS. By itself, this does not work as if you returned a JPEG or a ham sandwich.
When content gets zipped on the fly, the answer is slightly different - the answer says "I am text / css, but it seems to be gzip encoded for transmission." The browser can see this.
Some web servers like Apache will do something for you if you supply gzipped files locally. But I think your server is down.
Why does this work for HTML? Hmm, I don't know, maybe your browser actually manages to sort out this particular case?
What you ultimately want to do is respond to the Content-Type: text / css and Content-Encoding: gzip request so that it is recognized correctly.
a source to share
it runs on Localhost on your own server (eg XAMPP)
then you need to set up the .htaccess file to send the right
that says the files can be gziped.
try adding this file to your main .htaccess file:
AddEncoding x-gzip .gz
AddType text/html .gz
and make sure the gziped compressed
files endind with a .gz extension .
also always run this on the server .. :)
a source to share