I’m working as a client-side developer on a web app and found myself having lots of modules, each one for different pages. I wonder is it a good idea to do include depending on route myself (in javascript) or pass this responsibility to back-end (ruby on rails) guys.
I suppose I need some application.js to be included in every page, and in it do something like this:
if (window.location.href == '.../somePage') {
loadScript('somePageControls.js')
}
if (window.location.href == '.../anotherPage') {
...
}
Any thoughts?
ok, this is not a simple answer at all, since there are you and there are theese ruby-guys, hope everything is ok beetwen you! 😉
although if you don’t want to bother too much theese guys, ( i know it not easy to work in team ) you can ask to include just one ruby file from your working folder ex.
now you can work with this unique file and load from here all the js file you need. by using for eaxmple a switch-case