The best practice is to create relatively small files for development purposes, where each file contains a module of functionality that is all connected (which is most effective for developing / debugging / editing / source control. You can give each file a meaningful name that describes what is in it. Each these files can be managed separately (their own version history in your version control system, check / check, etc.). It is often easier to open several tabs with separate files in your editor than the priests Use bookmarks to navigate between different places in one large file, etc.
Then, when you deploy the application, you use a tool (for example, closing Google or YUI Compressor) to minimize and merge all your smaller files into a single deployment file. This preserves the advantages of developing smaller files that contain related code, while retaining the advantage of deploying that most / all of the code is in one larger external javascript file that can be loaded into a single HTTP request and can be cached very effective.
source share