Comment to 'Developer Question: New Module'
  • 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.