views:

162

answers:

3

In my project i have a lot of css styles. Some of them are never used (not anymore). I check this manually with eclipse: i select text and then with "Search -> Text -> Project" i can find, if this style occurs only in the stylesheet or also in java files. Is there better way to check, which styles are currently used in my GWT project?

edit: @Igor,Keith: thanks for the hint, but i'm not using the CssResource to insert my css file. Instead i use my index.html. And i want to remove the unused styles just for better overview. CssResource is not exactly, what i'm looking for.

+1  A: 

If you use CssResource to inject your css file, GWT will handle pruning unused styles for you (just like it does in the case of unused code). It will also by default obfuscate it, so watch out for that. For a comprehensive explanation see the docs.

CssResource works best in combination with UiBinder. I'd recommend both - you even get cool features like compilation-time errors when you are missing a CSS style in your UiBinder xml files (or you misspelled it), among other cool/awesome things - again, check the docs for the full list.

Igor Klimer
see my edited post.
cupakob
+1  A: 

GWT 2.0 added a feature called ClientBundle, which is a generic mechanism for bundling resource files such as images and CSS. If you bundle CSS files with ClientBundle (via the CssResource class), the GWT compiler can actually generate errors on unused CSS selectors.

The documentation is a bit rough, but here is the relevant part of the GWT docs:

http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#Strict_scoping

In addition to detecting missing selectors, CssResource also supplements CSS itself, letting you use constants and conditionals within your CSS, even allowing you to specify different styles depending on which browser is being used. It also provides obfuscation and minification, among other things.

Keith Platfoot
Ah, you beat me to it, Igor. I guess I need to refresh right before submitting an answer. :-)
Keith Platfoot
see my edited post.
cupakob
A: 

I'm still looking for a better solution. To solve the problem i've used the linux terminal instead eclipse for the search and that was faster.

cupakob