Given that:
- The asset pipeline is fairly complex (coming from ASP.NET MVC, this is much more complex): How do I associate a CoffeeScript file with a view?
- All the js files will be loaded on each page and every "on ready" jquery method in each file will be executed
Does it make more sense to break the javascript for an application into "areas" -- one js file for the user/public area of a site, one file for the admin area of a site and so on. Scripts coming from external sites (jquery, other sites in the org) wouldn't really apply.
The upsides I see are
Performance: loading one 80kb file is much faster than loading 4 20kb files because of TCP/IP overhead (source). In production, all of the public js will be compiled into one file and served on every request, but I see downsides to including "admin" code in that file.
Security: there might be some things in script files that I don't want to expose to unauthorized users. Granted, if it's in script it's not secure, but it would be nice if I could minimize the exposure of things like paths to controller actions that perform database maintenance.
Simplicity in development: if the on-ready event will be firing off from each file, it makes sense to me to just put it in one file, that way I won't have to load each file to see what on-readys are in there. The js for sub-areas (like admin) would naturally be in a separate file that wouldn't come from assets
Related: Put javascript in one .js file or break it out into multiple .js files?