views:

870

answers:

4

I'm using Eclipse and the current solution (which I dislike) is to use "Search/Replace". This is an error prone solution.

Do you know any better approach to refactor JavaScript, HTML, CSS resources safely in big applications? Or do you use any other cool refactoring tool(s)?

+1  A: 

The trick is to maintain CSS clean and transparent from the beginning and clean it up as soos as things are starting to get messy.

CSS is one of those things that are terribly hard to clean up LATER.

Also, when naming selectors, choose names wisely in order to avoid coincidence with the other code of the application (at least when case-sensitive). This will help you with search & replace approach.

Developer Art
+1  A: 

Eclipse Galileo for Java EE 3.5 has built-in support for JavaScript, with auto-complete, refactoring, etc. For HTML/XHTML/CSS, I'm not aware of any special features to ease refactoring apart from the project-wide search/replace.

From this point of view, IntelliJ IDEA seems thus to have much better support. See:

Pascal Thivent
Eclipse's Javascript refactoring is not very good. It NPEs whenever you try to extract method, and its rename misses regularly.
Sean McMillan
A: 

One possibility that I've come across (though haven't used extensively yet) for css is: https://addons.mozilla.org/en-US/firefox/addon/5392

The Dustme Selectors firefox addon, which is supposed to let you weed out css selectors that aren't used when you browse a subset of pages.

Another solution that I have used for minor css checks is: http://www.cleancss.com/

Some of the "color word to color code efficiency changes" are probably very minimal unless you have a large number of occurrences of them, but it's useful for analysis in general as well.

Tchalvak
A: 

Check out CodeRush, a plugin for MS Visual Studio. It claims to support over 50 different refactorings for JavaScript. http://stackoverflow.com/questions/2432256/how-far-did-devexpress-get-with-javascript-refactoring

Hope that helps!

Raja