缩小如何正确地删除空格和注释行 [英] how minification works exactly to remove spaces and commented lines

查看:73
本文介绍了缩小如何正确地删除空格和注释行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



在缩小过程中,它会删除CSS和js文件中的注释和空格。

工具如何工作?

它将读取整个文件以查找注释,空格并删除该行或者它将如何工作背景?



任何一个可以帮忙。





谢谢

Hi All,

In minification process,it will remove comments and spaces from CSS and js files.
how the tool work?
It will read the entire file to find comments,spaces and remove that lines or else how it will work background?

Any one can help on this.


Thanks

推荐答案

它首先删除\r和\ n。然后替换所有其他控制字符,制表符和空格。

删除所有单行和多行注释(//和/ * /)

也替换所有类型单个空格的空格。

所有换行符都用单个换行符替换。

同样替换变量名称,就像它将长变量名称替换为非常短的名称(例如,var declarevariable;非常简单的var a;)

因此它减小了大小并有助于提高性能。
It first removes \r and \n. Then replace all other control characters,Tabs and spaces also.
It removes all single line and multi-line comments (// and /*/)
Also replaces all kind of spaces with single space.
All runs of line feeds are replaced with single linefeed.
Also replace variable name like it will replace long variable name to very short name(E.g,var declarevariable; to very simple var a;)
Thus it reduces size and helps to increase performance.


这篇关于缩小如何正确地删除空格和注释行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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