Is there a good rule of thumb as to how big (in size) a JS file should be - that if it grows bigger than this it's good idea to split it into smaller files?
The same size as any other languages (never more than a few hundred lines), and the concat and minify at runtime (using the Closure compiler or the Yahoo libs or whatnot) is what we do.
More files = More HTTP Requests = Slower website
Develop in as many files as you want. Organize your code to keep development manageable.
Then, when you deploy, ship a minified/combined version of the code using a tool like Google Closure
Less files = less clean code = slower coding. Cost more than bandwidth.
Edit: if you really want to, you may have tool to merge them after you code of course.
All my JS files - one per function plus the libraries - are in one folder outside the public directory, the prioritary ones start with one or two underscores. In my index page, a PHP script from a static server is called. It checks whether or not the compressed JS file exists. If it does not, a scandir is performed on the JS directory, and each file is included in a buffer, then compressed, and put into a single file. And it outputs the content of this file.
If I change/add/delete a js file, all I have to do is delete the compressed file, and it will be recreated at the next load.
©2020 All rights reserved.