Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   HTML / XHTML / CSS (http://www.programmingforums.org/forum27.html)
-   -   Tool to find & remove unnecessary CSS? (http://www.programmingforums.org/showthread.php?t=10471)

Gumby Jun 21st, 2006 9:46 AM

Tool to find & remove unnecessary CSS?
 
Does anybody know of a tool that can search your css, html, jsp, asp, etc pages and find css that is duplicated or unnecessary and flag it for you?

angry_asian Jun 26th, 2006 11:50 AM

you can make your own in C++

Arevos Jun 26th, 2006 11:59 AM

Quote:

Originally Posted by angry_asian
you can make your own in C++

Uh, I don't think that helps a lot ;)

Besides, so far as I can see, the problem isn't a trivial one to solve. You'd need a CSS and HTML parser just to get started.

angry_asian Jun 26th, 2006 12:05 PM

cant you make a text editor in C++ that does that?

titaniumdecoy Jun 26th, 2006 12:25 PM

HTML TIDY is a good tool for cleaning up HTML. I don't think it works on CSS, however.

DaWei Jun 26th, 2006 12:31 PM

I've used Tidy. I think it doesn't meet the OP's desires. He is out to find and remove duplicate or unnecessary stuff, not just correct poorly written code. How one defines "unnecessary" is obviously a factor. Even so, as Arevos mentions, it wouldn't be a trivial process. I'd rather ask if someone knows of one, than write it.

Arevos Jun 26th, 2006 12:53 PM

Quote:

Originally Posted by angry_asian
cant you make a text editor in C++ that does that?

You can potentially make it in any language. It would just be a lot of hard work, and presumably that's something Gumby wanted to avoid in the first place.

I don't think C++ would be a very good language to write it, however. It doesn't particularly matter if a parser takes 100ms or 10'000ms, and efficiency is really C++'s only advantage over other languages that may be better suited for the task. Knowing when to use a language is rather important, and C++ doesn't seem like the right tool for the job in this case.

Java has a lot of libraries revolving around XML DOMs, and I ran across CSSEngine for Python, which looks interesting. Javascript may also be a possibility, as you can take advantage of the browser's DOM parsing without extra libraries.

However, the most efficient solution may be to do it all manually. Or find a program that already does what you need.

melbolt Jun 26th, 2006 1:13 PM

maybe try visual studio.

I don't know how it works on CSS but for HTML you can go into the options and make it very anal about your code, check to make sure it meets certain standards, it will pick out every little potential wrongdoing if you set it to do so.

DaWei Jun 26th, 2006 3:47 PM

Again, it isn't about wrong or dirty code. It's about duplicate, unnecessary code. One might be defining the style of the "blah" class forty-leben times, all quite beautifully.

Gumby Jun 28th, 2006 10:35 AM

Quote:

Originally Posted by Arevos
...
However, the most efficient solution may be to do it all manually.
...

Pretty much what I've been doing anyway. It's not really too big of a deal though, it's just that every so often while looking through the HTML / CSS files I catch extra stuff that's not needed, and I just figured it'd be nice if there was something to just catch it all automatically, instead of finding little things here or there, or sitting down and searching through 30 files manually. :eek:


All times are GMT -5. The time now is 8:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC