为什么人们缩小css和javascript,当我们有gzip? [英] Why do people minify css and javascript, when we have gzip?

查看:168
本文介绍了为什么人们缩小css和javascript,当我们有gzip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么人们经历了缩小 javascript css 文件的所有痛苦,如果他们只需打开 gzip compression 在Web服务器上?

Why people go through all the pain of minifying javascript and css files if they can just turn on gzip compression on the web server? This will give the same (or even better) result in traffic preformance.

这样做会带来额外的好处吗?

Does minification give additional benifits?

推荐答案

您可以使用gzip(通常内置在Web服务器中)与Minification结合使用。但是,如果删除注释,将较长的变量重命名为较短的变量名等,则会导致gzip无法执行大量额外的操作。

You can use gzip (which is usually built into web servers) in combination with Minification. Minification does a lot of additional things that gzip can't, however, like removing comments, renaming long variables to shorter variable names, etc.

生成的传输数据可以是显着小于简单地压缩原始的.js。这显然取决于源.js。

The resulting transferred data can be signicantly smaller than simply gzipping the original .js. It depends, obviously, on the source .js.

您可以查看Compressorater( http ://compressorrater.thruhere.net/ )。你可以抛出你的.js,它会缩小使用各种库与gzip和没有gzip,并显示你的结果。你可以看到简单的gzipped和gzipped +缩小的各种库之间的比较。

You can check out Compressorater(http://compressorrater.thruhere.net/). You can throw in your .js and it will minify using a variety of libraries with and without gzip and show you the results. You can see the comparion between simply gzipped and gzipped + minified by the various libraries.

这篇关于为什么人们缩小css和javascript,当我们有gzip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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