A script module is a special case of a script policy. A script module provides (exports) a set of features, and other policies and/or variants use (import) these features. A feature is a unique identifier for some functionality. It can refer to a single piece of functionality on a device, or to a functionality provided by a part of the application. Please refer to the topic entitled Features for a complete list of features exported by MCS.
A script module is a special case of a script policy. A script module provides (exports) a set of features, and other policies and/or variants use (import) these features. A feature is a unique identifier for some functionality. It can refer to a single piece of functionality on a device, or to a functionality provided by a part of the application. Please refer to the topic entitled Features for a complete list of features exported by MCS.
Some features exported by a script module may not be supported on some devices. If a script module contains a variant for the selected device, then the features are assumed to be supported on that device, otherwise they are not.
Adding a feature to the page also means adding all of its imported features. Each imported feature has a Use attribute associated with it. This attribute determines how the feature will be used by the variant. After the whole page has been processed it will have a set of used features. Those features need resolving to a set of script modules that provide all used features, so that the scripts can be included in the page. This resolving relies on the mapping created during the script registration process. If there is an overlap between the sets of imported features, then the use from the variant wins.
If an imported feature is marked as 'used', then it is required and must be supported by the device.
If an imported feature is marked as 'optional', then it is added to the set of used features only if it is supported.
The purpose of the 'unused' value is to allow a variant to remove an imported but unnecessary feature. If, after resolving, any of the features has the Use attribute of 'unused', then it will be removed from the set of features.
When a feature imports other features, then the features that enhance the imported feature come before those that use the imported feature. For example, the cf2:dom.Element#Styles feature enhances the cf2:dom.Element feature that is used by the cf2:dom.ElementAccess feature. If all three features are used in a page, then they will be imported in the following order:
cf2:dom.Element
cf2:dom.Element#Styles
cf2:dom.ElementAccess