Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否需要增加压缩JS的脚本? #419

Open
luke-yeah opened this issue Aug 2, 2019 · 3 comments
Open

是否需要增加压缩JS的脚本? #419

luke-yeah opened this issue Aug 2, 2019 · 3 comments

Comments

@luke-yeah
Copy link

luke-yeah commented Aug 2, 2019

目前是通过Java的工具进行压缩的。
参考Issue #201

可以考虑增加压缩JS的脚本,建议通过npm安装开发依赖google-closure-compiler,这样修改源码后可以输出*.min.js文件。

@luke-yeah
Copy link
Author

使用以下2种方式都无法得到跟作者一样的压缩结果,作者@zTree能否说明下?

java -jar ./build/closure-compiler-v20190709.jar --js_output_file='src/js/jquery.ztree.core.min.js' 'src/js/jquery.ztree.core.js'


## 或者
npm install -D google-closure-compiler
google-closure-compiler --js="jquery.ztree.all.js" --js_output_file="jquery.ztree.all.min.js"

@zTree
Copy link
Owner

zTree commented Aug 6, 2019

等我有空测试看看,毕竟一个是 java 包,一个是 js 包,我也不敢保证 compiler 的 java 和 js 版本可以得到 100% 一样的结果

@luke-yeah
Copy link
Author

等我有空测试看看,毕竟一个是 java 包,一个是 js 包,我也不敢保证 compiler 的 java 和 js 版本可以得到 100% 一样的结果

目前看,Java/JS均使用 v20190709版本,压缩后的结果是一样。

但是,对比原始的*.min.js文件,会增加一些信息:

var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(k){var r=0;return function(){return r<k.length?{done:!1,value:k[r++]}:{done:!0}}};$jscomp.arrayIterator=function(k){return{next:$jscomp.arrayIteratorImpl(k)}};$jscomp.makeIterator=function(k){var r="undefined"!=typeof Symbol&&Symbol.iterator&&k[Symbol.iterator];return r?r.call(k):$jscomp.arrayIterator(k)};
... 其他信息

测试demo的话,并不影响使用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants