Javascript include control depending on page
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?
Javascript include control depending on page
===

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?