views:

229

answers:

2

Hey guys!,

Does anyone know what might be causing this to happen?

The file is uploaded correctly, it has the right permissions, and the <script> tag points to it correctly.

The command I ran on the file was:

gzip file.js

What could it be?

A: 

Are you just trying to use the javascript file? Try pointing your browser at it, it may look quite garbled. GZIP is for file level compression not minifing javascript.

Daniel A. White
when go to the file directly, it just pops up a download dialog rather than showing me the file like a normal js file would.I was under the impression that i could gzip js files manually so the server didn't have to on each request.. Isn't it possible?
I would guess that your response headers are incorrect, if you just upload a gzip the response header content-type is probably going to be 'application/x-gzip' when for the browser to interpret it correctly it needs to be be 'text/javascript'.
Richard M
A: 

There are two concepts here: Type of the file and the Encoding used for transmission. You have to arrange for the server to know that the Type is application/x-javascript and the Encoding is x-gzip. Whether that gzip encoding happens on the fly at every download, or is done once in advance depends on server configuration.

Am I allowed to cite external web pages? Here's an example from somebody else's web page for how to configure Apache to support pre-compressed JS and CSS files:

# Compressed javascript files
AddEncoding x-gzip .jgz
AddType application/x-javascript .jgz

# Compressed css files
AddEncoding x-gzip .cgz
AddType text/css .cgz

Configuration for other servers (non-Apache) or for dynamic (not pre-compressed) server-side compression will differ.

Liudvikas Bukys