I'm working on a project that has a massive
script.js file where all the shared functions, code and more is placed; but it also has code that has some page-specific behavior.
Evidently, this causes issues in certain ways as including the line
$('#bank-account').on('change' ... in those files that are not the one it is supposed to be run at, will trigger some random behavior.
Talking about static file serving, it's better to server 1 file than multiple files, and for that reason people
minify JS files. This usually take place on application-level code, like libraries or code that must run in all pages.
My question is, what about page-specific behavior? where should I be placing it? Take for instance something as simple as initializing a select library like
$('#mySelect').select() or something as complex as a
React object to create a data-driven component on that specific page.