How to remove HTML comments from pages before deployment?

During development, we tend to put a lot of comments into HTML pages or we can comment on some things according to the request to configure the end user. When working with hundreds of pages, how to ensure that all commented text is deleted before final deployment. Because packaging the comment pages for everyone else, I suggest bad practice. So, any good tool that can be built into a build script to execute them?

+4
source share
3 answers

I use this: Absolute HTML Compressor

This is great and , it does NOT modify / optimize the source code , it only does what you ask for it. I personally ask only to remove comments and spaces at the beginning of each line . From the command line or in a batch file:

ahc "path/file.html" -y- -l- -q- -w+ -t- -c+ -d- -m- -b- 

WARNING: the -b- option (I used above) disables the backup, so the file will be overwritten.

By the way: it also has a very nice GUI to use without a command line if you want.

+3
source

If you are not using server-side scripts, you must disable them manually.

If you use server-side scripts, you can use a regular expression. just google to “remove html comments” and your server-side scripting language.

-1
source

Source: https://habr.com/ru/post/1300989/


All Articles