使用gzip压缩JavaScript [英] Compress JavaScript with gzip

查看:113
本文介绍了使用gzip压缩JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google PageSpeed Insights优化我的网站,并建议使用gzip存档众多JavaScript文件。

I ran Google PageSpeed Insights to optimize my site and it recommended archiving the numerous JavaScript files with gzip.

这是如何工作的?如何将文件导入/包括为存档文件?

How does this work? How are the files imported/included as an archive? Can they all be inside one big archive, or should they be individual archives?

推荐答案

您可以将您的网络服务器配置为执行以下操作:压缩为你;在 Apache 的情况下:

You can configure your web server to do the compression for you; in the case of Apache:

AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

这篇关于使用gzip压缩JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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