How to hide or remove comments in browser view page source?

At the moment I decided to use php to create html and jquery comments to hide them in view source

like

<input type="submit" value="Submit">
<?php //this is comment regarding input ?>

Possibly it affects performance... but found no other way

Regarding jquery one note.

//$('#upper_level_id0').css('color', 'red');<?php //works ?>
$('#upper_level_id'+index).remove();

In this example $('#upper_level_id'+index).remove(); does not work.

$('#upper_level_id0').css('color', 'red');<?php //works ?>
//$('#upper_level_id0').css('color', 'red');
<?php //works ?>
$('#upper_level_id'+index).remove();

But in this example all works. So conclusion that <?php comment better tos start in new line


Well you cant do that. But before you upload the html files to your server you can minify the source and upload them. But before uploading check if everything is working as expected or not. Try this website.

http://www.willpeavy.com/minifier/


The source view shows the source. You have no control over how the browser will render it.

If you don't want comments to show up when the user of the browser views the source, then don't put them in the source that your server delivers to the browser.

Tags:

Html

Comments