Does anyone know of an online parser to automatically remove ALL comments EXCEPT for necessary conditionals? ie
<!--[if lt IE 9]>
I tried various forms of HTML5 minification but its buggy
Also saw these php solutions but would prefer to use an online parser if one already exists Removing all html comments except internet explorer comments using regex and php
Stripping HTML Comments With PHP But Leaving Conditionals
Here, just made one for you: http://jsfiddle.net/DerekL/BUVkS/show/
If you want to see the source, it is here: http://jsfiddle.net/DerekL/BUVkS/
Put your HTML code inside, then click remove comments.
It will then remove all comments and left with the conditionals.
(Used that PHP regular expression you put (the link) and I put it into JavaScript plus a little modification to match newlines)
/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->)(.|\n))*-->/g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With