我怎样才能gzip压缩我的JavaScript和CSS文件? [英] How can I gzip my JavaScript and CSS files?

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

问题描述

我有一个问题,我要gzip压缩的原型库,但我完全以不知道如何做到这一点,从哪里开始,它是如何工作的。 :)

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文件:

So I have a folder with my JS Files:

/ COM pressed / 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

/com$p$psses/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模块自动COM preSS在飞行的文件。

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服务器启用已输出COM pression,把上面的例子中为.htaccess文件。然后加载通过服务器HTML或js文件,并检查标头内容编码,如果说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天全站免登陆