如何在生成的HTML页面中隐藏JavaScript注释? [英] How to hide JavaScript comments in the resulting HTML page?

查看:140
本文介绍了如何在生成的HTML页面中隐藏JavaScript注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在结果页面源代码上隐藏JS注释? JS是通用的...

Is there a way to hide the JS comments on the resulting page source? The JS is generic...

谢谢!

推荐答案

。只需使用像JSMin这样的工具缩小您的JavaScript: http://www.crockford.com/javascript/jsmin.html

Sure. Just minify your javascript with a tool like JSMin: http://www.crockford.com/javascript/jsmin.html

或UglifyJS: https://github.com/mishoo/UglifyJS/
或Google关闭: https://developers.google.com/closure/

Or UglifyJS: https://github.com/mishoo/UglifyJS/ Or Google Closure: https://developers.google.com/closure/

它们都剥离注释和多余的空格。有些人甚至会以疯狂的方式改变你的变量名以保存字节。

They all strip comments and excess whitespace. Some will even change your variable names in crazy ways to save bytes.

或者将你的JS编译为JS语言,如咖啡脚本http://coffeescript.org/ ,它在编译时删除注释。

Or write your JS in a compile to JS language like coffee script http://coffeescript.org/ which strips out comments at compile time.

这篇关于如何在生成的HTML页面中隐藏JavaScript注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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