Starting on Mojito 0.5.0, we introduced a special group called app as part of the loader metadata. This new setting will group all the yui modules defined in mojito core and in the application, and will hold a series of settings and configurations that will define how YUI will deal with those modules when they are needed.
Groups are an important part of the YUI Loader configuration because they allow us to define buckets of files that could be loaded from different mediums and sources. For more details about the group configuration, reference to the YUI Groups config api: http://yuilibrary.com/yui/docs/api/classes/config.html#property_groups
By default, YUI defines 3 groups: default, gallery and yui2. In mojito, we introduce a fourth one, called app, and it defines anything that is part of the application or any of its dependencies, including mojito core modules. As a regular practice, mojito will assume few things about this group, and in many case, you don't need to worry about customize it, but if you need to, you can do it through the regular application.json configuration, using the yui.config structure. Here is an example:
[
{
"settings": [ "master" ],
"yui": {
"config": {
"groups": {
"app": {
"combine": false,
"maxURLLength": 516,
"base": "http://companycdn.com/path/to/files"
}
}
}
}
}
]
In the example above, we are configuring the application to load any YUI module defined in our application or mojito core from a custom CDN rather than from the NodeJS server that runs our application.
As part of mojito 0.5.0 release, we also ship an extended version of the mojito-handler-static middleware that implements a fully functional, fully capable combo handler, which supports cache, fallback when proxies cut the url, etc. This combo follows the recommendations described in this blogpost [http://www.yuiblog.com/blog/2012/11/06/managing-your-javascript-modules-with-yui-3-stockpile-2/] from John Lindal (@jafl5272), and it is the default configuration used for the mojito application if the app group is not configured, and it will have these default settings:
- comboBase: "/combo~"
- comboSep: "~"
- root: ""
- maxURLLength: 1024
Another useful mechanism to control the app group is by inheriting some of the settings from the default configuration, like the combine flag. Here is another example where we disable the combo handler while in development environment:
[
{
"settings": [ "environment:development" ],
"yui": {
"config": {
""combine": false
}
}
}
]
By doing that, YUI Core modules will not be using the combo handler, but also the app group will inherit that configuration, but only then your application is running in the development environment.
mojito-shaker 3.x extension will be able to control this setting if you decide to push your assets into a CDN like amazon. Shaker will also version the files and create the necessary rollups to speed up the caching and booting process in the client runtime, in case you decide to use it, you will not need to specify much though. Reference to shaker documentation for more details.