How to separate Controllers to avoid forced load/concatenation of ALL controllers

Dear Canvas team,

as our application is growing and growing, also the number of Controllers is doing the same. In the meantime, this became a critical mass, and it seems that by default, Canvas concatenates all .js files and delivers a huge .js code to the browser - even if a user just visits a single page and then leaves.

How would I structure the Controllers and what is needed to force the system only deliver the .js content of those Controllers to the browser that are needed for the current Template?

Do you have any example? I’ve seen that in the Canvas samples, there is a sub structure in the “js/Controllers” folder, but would that be sufficient? I dont’ think so.

Any suggestion very welcome, thanks,
Andreas

Yes, absolutely correct. All files in js folder will be loaded in to the app in one js file. To overcome the files being loaded in to one file. You could add the files to files folder and load into the html. I have not tested the solution. Just a thought, since the files folder files can be accessed via canvas and the if html page has not loaded than the script will not load. Open to other suggestions.

Hi @andreas.franke,

As what @ishapiro has described, that should be one way you can do that.

To be more specific, JS files within js/controllers gets loaded automatically.

So you can either create a sub-folder in there or create it outside of the controllers or outside the JS itself to organize your files the way you would prefer it.

And also note that, if originally these files are directly under js/controllers already, moving them into a sub folder may need to restart the Cubewise Application Server service to remove them from the consolidated JS files. Other actions involving JS, CSS and HTML files are usually not necessary for restarting the Canvas service.


Cheers!
Paul