31

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)?

Alex Siman
  • 833
  • 3
  • 9
  • 18

6 Answers6

5

IntelliJ seems to support Javacsript/HTML/CSS refactoring out of the box.

ripper234
  • 222,824
  • 274
  • 634
  • 905
4

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
  • 562,542
  • 136
  • 1,062
  • 1,124
  • 3
    Eclipse's Javascript refactoring is not very good. It NPEs whenever you try to extract method, and its rename misses regularly. – Sean McMillan Jul 14 '10 at 22:03
4

Because Javascript is weakly typed, effortless refactoring is nearly impossible. JetBrains Webstorm is the best thing out there that does something that "resembles" refactoring.

And please look at this comparison of Javascript refactoring of common Javascript IDEs : http://blue-walrus.com/2013/08/review-javascript-ides/

Oliver Watkins
  • 12,575
  • 33
  • 119
  • 225
2

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.

  • 3
    What if you inherit a project with hundreds of JS source files and realize that a variable has a misleading name? Wouldn't automatic refactoring help? – hidarikani Dec 31 '13 at 16:41
  • Surely this applies to all languages? The reasoning suggests that refactoring is something done by people who just can't write good code... – Joe Jul 11 '16 at 15:39
1

Check out CodeRush, a plugin for MS Visual Studio. It claims to support over 50 different refactorings for JavaScript. How far did DevExpress get with Javascript refactoring?

Hope that helps!

Community
  • 1
  • 1
Raja
  • 2,846
  • 5
  • 19
  • 28
0

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.

Kzqai
  • 22,588
  • 25
  • 105
  • 137