Comment to 'Developer Question: New Module'
  • That would include it every page load.

    I simply want it included on my modules pages. I get even more confused the more I look, because AddJs and AddCss are never in the same place. So your saying I could call the AddJs in my service block code?

    See, I'm getting lost because one thing UNA doesn't have, is a developer structure. Everyone kind of just does it however until it works. There should be a clear place to add js if I want it included on my modules pages alone. Same with AddCss

    Will this add it to the gzip, cached output?

    • The general rule is to call the addJs|Css whenever needed. I.e. if the template method depends on some JS or CSS then call addJs|Css in that method for the related files. Also instead of having a large single main.js where you put all of the code regardless of a page/section/block it is better to have logically separated files (view.js, edit.js, view.css, manage.css, etc.) and add/include them where necessary in the respective methods, blocks.

      In case for some reason you'd like your main.js to be included always for all of your module's pages then you may try to put the addJs into the template's constructor.

      And yes, the caching and gzipping happens automatically.