如何gzip我的JavaScript和CSS文件? [英] How can I gzip my JavaScript and CSS files?

查看:106
本文介绍了如何gzip我的JavaScript和CSS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我必须gzip原型lib,但我不知道如何做到这一点,在哪里开始,它是如何工作的。 :)

I have a problem, I have to gzip a prototype Lib, but i totaly have no idea how to do this, where to start and how does it works. :)

我找到一些教程,但是没有帮助...

I find some tutorials but that wasn't helpful...

与我的JS文件:

/ compressed / js /
1.js
2.js
3.js

/compressed/js/ 1.js 2.js 3.js

我正在调用这些文件以进行测试。

I'm calling these files for a test in this file

/compresses/index.php

/compresses/index.php

<link rel="javascript" type="text/js" href="js/tabs.js" />
<link rel="javascript" type="text/js" href="js/fb.js" />

那么我该怎么办呢? :)

So what do I have to do? :)

推荐答案

您可以使用apache的 mod_deflate 自动压缩您的文件。

You can use apache's mod_deflate to automatically compress your files on the fly.

示例:

AddOutputFilterByType DEFLATE text/html text/xml text/css text/javascript 

要检查您的apache服务器是否已启用输出压缩,示例上面的.htaccess文件。然后通过服务器加载html或js文件,并检查标题为Content-Encoding,如果它说gzip或deflate,它是启用。

To check if your apache server has already output compression enabled, put the example above into an .htaccess file. Then load an html or js file via the server and check the headers for "Content-Encoding", if it says gzip or deflate, it is enabled.

这篇关于如何gzip我的JavaScript和CSS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆