For a new page I'm working on, I want to make sure I do everything “right” to the best of my ability. I was wondering what the best practices were re. one JS file per page or one file containing everything. I found this question which helped some, but raised more questions.
I pretty much only use JS for three things:
- transitioning things on button clicks (showing/hiding panels, etc.),
- pre-validating forms, and
- AJAX calls.
When I compare my use cases to the namespacing approach, it seems like overkill; I don't really understand why I would need to set up such a complex framework to work with JavaScript. This leaves me with two questions:
- For what I'm doing, should I use one JS file per page, or use Irish's namespace technique and a single script import?
- What the hell are people using JS for that requires so much structure?