Hacker News new | comments | show | ask | jobs | submit login

I do this as well. I break apps into "components" -- each component has it's own CSS and JavaScript file. A component covers a logical domain, such as administrative functions, or a reporting piece.

Then I have an application level CSS&JS that has everything generic in it. This is for a reasonably big app, so the overhead of having a single CSS/JS isn't insignificant - particularly when supporting mobile devices.

The other useful thing is a I as a dasherized version of the controller name and action to the body tag - as an id and a class respectively. So the body tag is something like <body id='my-controller' class='show'>

I also expose these as JavaScript globals CONTROLLER and ACTION (I also have LOCALE and COMPONENT).

These constructs are to be used sparingly -- you don't want to mash everything together too much -- but they're very handy when used right.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact