压缩代码的好处:减小了文件的体积,减小了网络传输量和带宽占用,减小了服务器的处理的压力,提高了页面的渲染显示的速度,代码相对更安全了
之前找了个node的压缩工具,还需要自己编译,然后报各种错误,确实不太会用,所以就找了个Go语言的。直接下载exe运行十分方便。
Github:minify
进去直接下载发行版的即可。
css text/csshtm text/htmlhtml text/htmljs application/javascriptjson application/jsonsvg image/svg+xmlxml text/xml
原版教程(经过机器翻译)
Usage: minify [options] [input]Options:-a, --all 缩小所有文件,包括隐藏文件和隐藏目录中的文件-b, --bundle 通过连接将文件捆绑到单个文件中--cpuprofile string 导出CPU配置文件--css-precision int 要在数字中保留的有效位数,0表示全部(默认为0)-h, --help 显示用法--html-keep-comments Preserve all comments--html-keep-conditional-comments Preserve all IE conditional comments--html-keep-default-attrvals Preserve default attribute values--html-keep-document-tags Preserve html, head and body tags--html-keep-end-tags Preserve all end tags--html-keep-quotes Preserve quotes around attribute values--html-keep-whitespace Preserve whitespace characters but still collapse multiple into one--js-precision int Number of significant digits to preserve in numbers, 0 is all (default 0)--js-keep-var-names Preserve original variable names--json-precision int Number of significant digits to preserve in numbers, 0 is all (default 0)-l, --list 列出所有接受的文件类型--match string 使用正则表达式进行文件名模式匹配--memprofile string 导出内存配置文件--mime string Mimetype(例如text/css)是输入文件名的可选选项,优先于--type-o, --output string 输出文件或目录(必须有尾随斜杠),留空使用标准输出-p, --preserve[=mode,ownership,timestamp] 保留选项(模式、所有权、时间戳、链接)--preserve-links 复制符号链接而不取消引用,也不缩小引用的文件(仅使用--sync)-r, --recursive 递归缩小目录--svg-precision int 要在数字中保留的有效位数,0表示全部(默认为0)-s, --sync 将所有文件复制到目标目录,并在文件类型匹配时缩小--type string 文件类型(例如css),输入文件名可选--url string 启用URL缩小的文件的URL-v, --verbose Verbose--version Version-w, --watch 查看文件并缩小更改--xml-keep-whitespace 保留空白字符,但仍将多个字符折叠为一个Input:文件或目录,留空以使用stdin
minify.exe D:\Code\enian_blog_dev\profile -r -o D:\Code\enian_blog_dev\profile_min


正在学习Go语言的PHP程序员。