JavaScript styleguide on organizing files

Viewed 3182

I have worked in a web project with a heavy part on JavaScript, and I have noticed that there was no style how to use JavaScript. What unsettled me most is that everyone added files here and there, which resulted in a mess to organize and deliver them. Because this will be happen in every new project, I would like to have something like a styleguide for JavaScript. This styleguide should address the following questions:

  • How should JavaScript files be organized in the file system during development?
  • How should the JavaScript parts be separated from the HTML and other parts of the application?
  • How should JavaScript files be delivered in the real application, so that less code has to be loaded on each request and not too much requests have to be sent?

Is there something public available as a starting point for developing our own styleguide? What are your experiences in using your styleguide? Are developers following it easily, what are the simple and what are the difficult parts in it?

(I know, more question than one, but I'm interested in the whole story here. As a background, we have used JQuery and JSF, but I don't think that will have an impact on the answer.)

4 Answers
Related