保留条件注释的缩小器?
我尝试了在线 JS Minifier 但它会删除条件注释,例如:
var u = navigator.userAgent;var e=/*@cc_on!@*/false;
BECOMES
var u=navigator.userAgent;var e=false;
这会影响操作因此,我正在寻找一个可以智能地保留这些和任何此类注释的缩小器,而不是手动添加删除的注释。
I tried out the online JS Minifier but it cuts out conditional comments like:
var u = navigator.userAgent;var e=/*@cc_on!@*/false;
BECOMES
var u=navigator.userAgent;var e=false;
This would affect the operation of the code, so instead of manually adding the stripped out comments manually, I'm looking for a minifier that intelligently preserves these and any such comments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据报道,YUICompressor 可以满足需要。 以下是博客的摘录:
...
但不用担心,事情并没有你想象的那么糟糕。 不幸的是,JSMin 删除了条件编译注释,但我相信这是由于有一段时间没有更新,并且没有跟上现代 Web 开发实践的速度。
使用其他工具(例如 YUI 压缩器或打包器)确实可以很好地处理条件编译。
...
您可以在 http://robertnyman 阅读整篇文章.com/2008/05/26/conditional-compilation-in-javascript/
YUICompressor reportedly does the needful. Here is an excerpt from a blog:
...
But fret not, it’s not as bad as you think. Unfortunately, JSMin removes conditional compilation comments, but I believe this is due to not having been updated in a while, and not up to speed with modern web development practices.
Using other tools such as YUI compressor or packer does indeed work fine with conditional compilation.
...
You can read the entire post at http://robertnyman.com/2008/05/26/conditional-compilation-in-javascript/
还有 YUI Compressor 的 .NET 端口,它允许您:-
。 因为这是 Vinnie 和 Crescentfresh 上面提到的(原始)java 版本 YUI Compressor 的端口,它应该给您相同的结果,但全部在 .NET 环境中 - 不需要 java。
HTH。
There's also a .NET port of YUI Compressor which allows you to:-
because this is a port of the (original) java version YUI Compressor, which Vinnie and Crescentfresh mention above, it should give you the same results BUT all in the .NET environment -- no need for java.
HTH.