Monday, May 14, 2007

Idea: CSS Comment Stripper

Update: StripMe.org is live. Yandleblog post about it.


I recently read a post on a local mailing list where someone emphatically said "style sheets should not have comments in them. Ever." (or something along those lines). But of course comments are very hand things to have, especially I someone else is eventually going to have to ork with your files.

This got me thinking that maybe someone should build a server-side application that strips comments comments from your CSS.

That's when I hit upon this idea (maybe an idea for a £5 App).

The "Stripper"

Initially, I tought it could work a bit like tinyurl:
  1. Go to http://stripme.org [nothing there yet]
  2. Enter the address of your CSS file (e.g. hobointernet.com/contentStyles.css) in a form
  3. The site gives you a URL for a version of the CSS file sans-comments, e.g. http://stripme.org/234cvfrv.css
  4. (in your HTML) link to this URL instead of linking directly to your CSS
Then, having talked the idea through with Ben, I realized that there's a simpler, more RESTful way of doing it…
  1. (in your HTML) link to http://stripme.org/http://hobointernet.com/contentStyles.css
…the service returns your CSS file without comments.

This method has the advantages that the originating file in not hidden (so people can get to your comments easily), it's really easy to remember and there's no forms.

Got Several style sheets you want to get concatenated into one? No problem, just use a URL like:

http://stripme.org/http://hobointernet.com/contentStyles.css+contentStyles.css

I might talk about this idea after Dan Glegg's talk at the next £5 -Apps meet.

3 comments:

Ian Ozsvald said...

Hey Danny, this sounds like a nice topic to discuss! I've blogged about it.

John Montgomery said...

Definitely a £5 app idea there! I can already think of a few issues, but that's just means more to discuss.

John Montgomery said...

Oh and a quick thought - you could use this approach to support different syntax for CSS (maybe to allow an easier specification of styles in a hierarchy).