shinve — 2011-11-08T03:15:02-05:00 — #1
fenitra — 2011-11-08T03:21:48-05:00 — #2
I do not find unless you hand-made
l4dd13 — 2011-11-08T03:56:55-05:00 — #3
Similarly for CSS use a CSS Compressor.
My personal preference is http://www.refresh-sf.com/yui/
For HTML you could write a PHP script which read the html files and use regular expression to locate and remove the comment blocks.
As for removing comments in PHP script, that's something I've never looked into so you're on your own with that one. Are they doing any harm?
How big are your PHP comments? If you were to remove them would your script file sizes be dramatically reduced?
shinve — 2011-11-11T19:24:14-05:00 — #4
I will have to look into it some more then for php. What you suggested might be an interesting regular expression exercise. Thanks for the other suggestions. I comment all the time, in part for best practices, and mostly because I script a lot of programs/run a lot of tests just to see what will happen. So depending on the type of exercise (php, css, js) my comments can sometimes be longer than the program itself, especially on a character by character basis. (I remove some of the more obvious comments before production, but there's often a lot left.)
theoriginalh — 2011-11-11T21:22:59-05:00 — #5
Are you on Mac? bbEdit is certainly capable of what you're looking for in the right hands - and is a bargain in the app store these days
shinve — 2011-11-11T21:27:03-05:00 — #6
Currently using Windows, so it won't for me. Good suggestion though.
stevie_d — 2011-11-12T08:59:39-05:00 — #7
If you don't mind a bit of a brute force attack, Microsoft Word can do this. I'd recommend recording a macro, because it's pretty tedious, and that way you only need to go through the whole process once for each file type, and after that you can just press a button and have it all done by magic.
The key is to know that in the find and replace function, ^? represents any character.
So paste your HTML code into Word, and then do a serious of find and replace operations, in each case replacing the string with an empty string.
Start with <!-- ^? --> then <!-- ^?^? --> then <!-- ^?^?^? --> and so on.
It helps if you know what the shortest and longest comments you've used are, and that way if you know that you've never left a comment with fewer than three characters, you can miss the first couple of replacements out.
Same principle for comments in other languages, except that obviously you have to change the delimiters.
samanime — 2011-11-12T15:53:30-05:00 — #8
Microsoft Word... it makes me laugh, but it's true.
Just about any program with regex can do that as well.
For PHP comments, I wouldn't worry about removing the comments. They cause such a small overhead that it isn't a big deal.
For CSS, you can do a fairly simple regex to remove it. It differs depending what you are using, but if you did it with PHP, it'd be:
logic_earth — 2011-11-12T21:09:10-05:00 — #9
For PHP can use PHP itself from the command line...
> php --strip file.php > new_file.php
shinve — 2011-11-14T11:44:44-05:00 — #10
Thanks everyone. Excellent suggestions. I hadn't considered Word macros, and I didn't know about the strip file ability of php.
stevie_d — 2011-11-16T08:11:08-05:00 — #11
samanime may mock me for saying this, but I have often used Word to generate HTML. Not, I hasten to add, by using the "save as HTML" option, because that's on a par with rooting in bins for your dinner, but by using it as a plain text editor with a good search-and-replace function. Other useful 'special characters' are ^p (line break) and ^t (tab), which together have saved me countless hours when converting large tables into HTML, without having to go through WYSINWYG code stripping out all the crud. I'm sure there are other programs out there that can do it better, but I don't have them on my computer, whereas I do have an ancient, creaking but still functional copy of Word.