Hi I'm trying to remove all javascript comment (//) with in the HTML document. for example
<html>
<img src="http://example.com/img.jpg" />
<script>
//Some comments
gallery: {
enabled: true,
navigateByImgClick: true,
preload: [0,1] // Will preload 0 - before current, and 1 after the current image
},
</script>
</html>
Following is my regex code [^(http?s:)|ftp]\/\/(.*). This is working. But I want to make sure, Is there any way to improve this code. ?
console.log("this is a string with two slashes //");What if some non-URL, non-JavaScript part of your HTML had two slashes somewhere? As Mauno V. said, if you want to remove the comments from your JS, then minify it.