GZipping CSS和JS文件 [英] GZipping CSS and JS files
问题描述
我使用YSlow来提高我的网站的速度,我在使用压缩组件与gzip等级有麻烦。我有这个在我的.htaccess文件:
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text /纯文本/ xml文本/ css应用程序/ x-javascript
但YSlow正在说
有4个纯文本组件应压缩发送。
* 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
如何压缩css和js文件?
..我没有访问httpd.conf文件。
您可以在 http://crewinyourcode.com
更新:
AddType text / css .css
AddType application / x-javascript .js
到.htaccess,似乎没有帮助。
方案你有.css和.js的AddType行吗? Apache非常难以通过内容自动找出类型 - 它们看起来很像C代码。
尝试将这些行添加到.htaccess中。 。
AddType text / css .css
AddType application / x-javascript .js
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 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
But YSlow is saying
There are 4 plain text components that should be sent 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 the css and js files?
Also...I don't have access to the httpd.conf file.
You can see the problem at http://crewinyourcode.com
UPDATE:
Added
AddType text/css .css AddType application/x-javascript .js
to .htaccess and it didn't seem to help.
解决方案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
这篇关于GZipping CSS和JS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!