0

I'm using Enyo to build a web application; a "normal" way of organizing the files might look like this:

CSS: webapp/css
JS: webapp/js
Other stuff: webapp/assets

One of my co-workers had a seemingly good idea to co-locate the Javascript and CSS, so that a Javascript file (e.g. webapp/js/MyView.js) would have its CSS analog located in the same folder with it (webapp/js/MyView.css). This seemed like a good idea, but since I've never seen this done before I wanted to get a second opinion from the internets.

So, internets, is this a good way to organize Javascript and CSS code? Why/why not?

Travis Webb
  • 14,688
  • 7
  • 55
  • 109
  • Ok close-voters I get it. Maybe I am committing karma suicide with such a mushy question. But there exists a "code-organization" tag for a reason. I think this is a practical question with practical implications. But do what you will. – Travis Webb Oct 09 '12 at 20:29
  • 2
    Sorry, I still don't think this question is constructive enough for Stack Overflow. As an example, someone else could post the exact opposite answer to @thatidiotguy's, complete with `however you want obviously` and `personally, I would`, and nobody would be the wiser. In other words, `this question will likely solicit debate, arguments, polling, or extended discussion`. – Frédéric Hamidi Oct 09 '12 at 20:36

1 Answers1

4

You can organize your stuff however you want obviously. I just think having css in a folder labeled js is pretty misleading. If you want to put them in the same folder, call it media or something, not the same name that everyone associates with javascript files.

Personally, I separate images, js, css into folders of those names and it works fine for me, and I think it is quite standard. Another method is media/js, media/css, media/images if you like. As I stated personal preference, but something understandable and consistent.

thatidiotguy
  • 8,701
  • 13
  • 60
  • 105
  • I usually separate folders too. I'm mainly interested in the arguments (religious or otherwise) for and against this different practice. – Travis Webb Oct 09 '12 at 20:27
  • I just do not think anyone has super strong opinions about this as long as it makes sense, but I guess we will see. – thatidiotguy Oct 09 '12 at 20:28
  • Ok, thanks. That's one thing I'm also interested in -- if there aren't strong opinions either way, then that indicates the principle of what I'm doing might be ok. – Travis Webb Oct 09 '12 at 20:30
  • Inside the Enyo framework itself, we sometimes organize the js and CSS files together, and sometimes we have separate "js" and "css" directories. I personally prefer that the CSS and js files live together, but in something like our Onyx UI library, there are *a lot* of shared CSS classes, so it makes sense to just have one onyx.css file that everything references. At deployment time, we concatenate all those files together, so it's strictly a question of convenience during development. – Mark Bessey Oct 11 '12 at 07:19