When it comes to Scripting i can recommend creating at least one file per entity. If you are even more structure-freak as I am, then go even further and create a working folder on your PC and sourcecode system per entity, and have one “main” file.
E.g. for an Account entity I have a folder called Accountcode. In this folder I have a main file called Accountfunctions.js which is my main function library that I call from the Account form. Just like a traditional interface description file (including some code - though - for convenience).