Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A LAMP project I am currently working on is pretty well organized on the backend. However, there are a ton of pages that just have a diarrhea of javascript and html squirted all over numerous locations with little discernible architecture, rhyme, or reason. In a few cases, some kind of javascript prototype was created for a common control, and the MVC framework in place is taking care of templating pages.

How do we start to get all this spaghetti code under control? On backend projects I would start with getting some unit testing in place, CI, refactor common MVC or model/mapper code out etc..

share|improve this question
Talk about mixed metaphors! Diarrhea squirted all over... Spaghetti... – Jim G. Apr 3 '13 at 7:09

Do the same things. Unit testing is available via phantomjs or other runtimes and testing frameworks like Jasmine, Mocha, and etc. You might also look at Karma. It is possible to do CI builds using these tools.

You can refactor in JS just like you would in other languages.

In short, take all your knowledge for dealing with this problem in backend code and use the tools that are available to start applying it to your frontend code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.