Reputation: 47542
I have a Javascript file in which I have put a comment like the following so that it is easy for everyone to understand the code.
// This is a good comment
// another good comment
But this comment is rendered on the client side which I don't want. I just want comment for the developers which client should not inspect using the browser. I have tried following too but it didn't work
/* This is a good comment
another good comment */
Upvotes: 1
Views: 3482
Reputation: 1
If you are using PHP on your back-end you can just wrap every comment inside a PHP tag and it then gets removed by the server.
It probably is one of the easiest ways I can think of. But it just works when PHP is used. ;)
Upvotes: -2
Reputation: 958
Since Javascript files are classed as static content they're sent "as is", anything that's contained within them will be sent to the client unless it's specifically removed using some server side script.
One way to achieve this would be to use a minifier that strips out comments, most languages have modules you can use to do this on the fly.
Upvotes: 6