Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide JavaScript comments in the resulting HTML page? [closed]

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

Thanks!

like image 498
user1540714 Avatar asked Oct 23 '25 19:10

user1540714


1 Answers

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

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.

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

like image 161
Alex Wayne Avatar answered Oct 26 '25 10:10

Alex Wayne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!