Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Online parser to automatically strip ALL comments from HTML except for conditionals? [closed]

Tags:

comments

html

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

like image 327
Bachalo Avatar asked Apr 29 '12 20:04

Bachalo


1 Answers

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
like image 94
Derek 朕會功夫 Avatar answered Oct 05 '22 04:10

Derek 朕會功夫