I have a js file named script.js in the asset folder of my web application. But it goes bigger and bigger, so I want to split it into the different controler parts. For example I want to put all scripts that handle user actions in a file named user.js. And I want to put it into the folder view->user->user.js
The problem is that I don't know where to load these script. One solution may be to load it in the different views. (e.g. index.volt) But there is the problem that I have to change all views to include the js files.
I search for a solution that I can dynamicly load the scripts before accessing the controller action. Are there any ideas?
PS: I know that this system is slower than one script file, but it is more comfortable to have more little files when developing the application. When publishing this software I will use one script file for better performance.
Thank you for reading! :)