Skip to content Skip to sidebar Skip to footer

Gzipping Css And Js Files

I'm using YSlow to improve the speed of my site, and I'm having trouble with the 'compress components with gzip' grade. I have this in my .htaccess file: SetOutputFilter DEFLATE A

Solution 1:

Do you have AddType lines for .css and .js? It's pretty hard for Apache to automatically figure out the types by content alone -- they both look a lot like C code.

Try adding these lines to your .htaccess...

AddType text/css .css
AddType application/x-javascript .js

Solution 2:

Added, and it didn't help

Works for me, I'm now getting Content-Type: text/css and gzip encoding, which wasn't happening before due to the missing type mappings. That's something that should really be fixed server-wide though; it is a very broken server that cannot serve stylesheets and scripts with the right type.

Incidentally you should use text/javascript for scripts, for proper browser compatibility. application/javascript is proposed as ‘better’ for various nitpicking technical reasons, but it doesn't have the support so you can ignore that. x-javascript is long gone.

Post a Comment for "Gzipping Css And Js Files"