GZipping CSS and JS Files

I use YSlow to improve the speed of my site, and I am having problems with the "compress components with gzip" class. I have this in the .htaccess file:

SetOutputFilter DEFLATE AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript 

But YSlow says

There are 4 simple text components to send compressed

 * http://crewinyourcode.com/css/reset.css * http://crewinyourcode.com/css/inner-pages/index.css * http://crewinyourcode.com/script/css/jquery-ui-1.8.custom.css * http://crewinyourcode.com/js/inner-pages/index.js 

How can I gzip css and js files?

Also ... I do not have access to the httpd.conf file.

You can see this problem at http://crewinyourcode.com

UPDATE:

Added

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

in .htaccess and didn't seem to help.

0
javascript css gzip yslow
source share
2 answers

Do you have AddType lines for .css and .js? It's quite difficult for Apache to automatically determine types by content alone - both of them are very similar to C code.

Try adding these lines to your .htaccess ...

 AddType text/css .css AddType application/x-javascript .js 
+2
source share

Added and it did not help

Works for me, now I get the encoding Content-Type: text/css and gzip , which was not the case before due to missing type associations. This is what really needs to be fixed on the server; it is a very broken server that cannot serve stylesheets and scripts with the correct type.

By the way, you should use text/javascript for scripts for proper browser compatibility. application/javascript suggested as "better for various technical reasons, but it has no support, so you can ignore it. x-javascript long gone.

+2
source share

All Articles