I've been using JavaScript for quite some time now, and I've seen
several techniques regarding file organization. This is the last
technique I used on my last project:
I created a "JS directory" for external JS files. I then created one
global JS file for generic code that linked that all the web-pages
imported. For any JavaScript code that was specific to a page, I just
created a separate external JS file in the js directory for that page.
To sum it up: 1 external JS file for each web-page, and one global JS
file for all the web-pages.
Now, I got away with this only because the project that I was working
on had very few web-pages (i.e. less than 10 pages); however, even
with this small amount of pages, it started to become a nightmare
finding what I wanted; I can only imagine how ineffective this would
become if the project had 20, 30, or even 100+ pages.
I was hoping that some of you more "experienced" with JavaScript can
shed some light on this subject.