You can't, the point is that you download the html file and render it in a browser. One way around this is using server side rendering, but with a plain html file its warts and all...
You can use the <!-- comment tag --> syntax to prevent the browser from displaying things, but the site visitor can still see them via View Source or the developer tools. This may or may not accomplish what you want.
Cleaning up code before uploading production releases is the way to go.
Depending on your workflow, there are commands in text editors, command line tools or plug-ins for CMS for that task.
You can use the <!-- comment tag --> syntax to prevent the browser from displaying things, but the site visitor can still see them via View Source or the developer tools. This may or may not accomplish what you want.