HTML Comments
Hi all - is there a VS code extension or a quick way to delete comments on an HTML file before publishing? I’m using more and more comments to keep track of bits and pieces but I don’t want these on the published document. Thank you all!!
7 Replies
A VSCode extension is not going to solve this issue for you, since that is a tool for development and you're talking about a result that is seen in production. If those comments are unacceptable for you, take notes on a separate document. Otherwise you're going to have to go into the server hosting your html file and update them separately from your development ones. This is going to become tedious real quick, and very pront to error so I suggest you find another solution.
With that said, to address what you were actually asking for, you don't need any extensions for it. Just a simple search and replace using regular expressions:
![No description](https://cdn.answeroverflow.com/1199066285376544849/vscode.jpeg)
Thank you!! Wasn’t sure if there was another way but that’ll work fine.
This web dev stuff is still quite new but I’m building a site for a local sports community. Just using HTML and CSS at the moment (and a very small amount of JS - very small)
Thanks for your assistance!
No problem, remember to adjust the regexp to different files since CSS and JS use different style for comments.
There are tools that can do this for you, btw, which you will likely end up using anyway. One way to optimize the files to reduce their size is to minimize them which basically removes any and every non-essential character, including comments. But this will come with time so don't worry too much about it.
Knowing would beamazing if that’s ok?
Yes I'm just no sure of the exact tool, but using something like Vite or Webpack which are code bundlers would surely include that. If not, something liks PostCSS for sure has something to handle that.
Checkout Kevin's video on PostCSS, he talks about this type of stuff and even though it's mean for CSS there are equivalents for HTML and JS files as well.
Thank you!! Long way to go on this web dev journey!!!