What is the main purpose of JavaScript

Web resource dependencies

  • 2 minutes to read

You can define other dependencies between web resources. The main purpose of the functions is to allow mapping of string (RESX) web resources with the JavaScript web resources that are using them. This is also the way to configure web resources that require HTML web resources for offline use to also be available offline.

However, there are some other behaviors that developers using JavaScript web resources can take advantage of.

The image shows the following dependency tab within the web resource form. Dependencies between web resources are specified in the list above. Attribute dependencies are set using the list below. Attribute dependencies are only available for JavaScript web resources. More information: Attribute Dependencies

You can define dependencies within solution components within a solution. Up until the mode-driven apps, the main purpose of these dependencies was to prevent deletion of a solution component when another solution component depended on it. Mode-driven apps extend the behavior for JavaScript web resources so that any other web resource listed as a dependency for the JavaScript web resource is loaded with the JavaScript web resource.

Note

The dependency is only established after it is configured and the web resource has been published. Dependencies for unpublished web resources do not take effect once the web resource has been published.

The most common scenario is to map string (.resx) web resources with a JavaScript web resource that is dependent on it. There is a String (RESX) web resource for each language associated with the JavaScript web resource that is using it. When this JavaScript web resource is calculated, the values ​​are also automatically localized for the user's preferred language and the organization's base language is loaded so that they are available for all uses. Since you want to create solution dependencies between these resources, you also have the advantage that you know the dependent RESX resource, which is automatically loaded when you need it.

However, web resource dependencies are not limited to RESX web resources. You can map a JavaScript web resource to any other web resource to create dependencies that cause the associated web resource to load with the JavaScript web resource. This saves time by eliminating the need to explicitly load multiple web resources when registering a script in a form event, ribbon command, or ribbon activation rules. All you need to do is register the primary script and the dependency configuration loads the rest. You can also create a chain of dependencies because all of the JavaScript web resources that are calculated on the primary JavaScript web resource contain the web resources that are allocated for them.

Important

Web resource dependencies provide no control over the order in which the web resources are loaded. All web resources are loaded asynchronously and in parallel. If you have a JavaScript web resource that depends on or is being loaded and initialized by at least one other before the JavaScript web resource can be initialized, you must first manage that dependency differently.

Attribute dependencies

Starting with model-driven apps, if the JavaScript web resource depends on an entity attribute value that you do not want to display on the form, you can set the attribute as a dependency on the JavaScript web resource. This means that the attribute is available in the Client API attribute collection so that you can get or set the required value in your code. When you add a dependency in this way, the attribute's control collection is empty because there are only existing units in the form.

Before this function, you have to manually add the attribute to the form and then configure the controls that you want to hide. Now you can set up that dependency more directly, eliminating the possibility of someone removing the hidden field from the form.

See also

Web resources
Creating accessible web resources
Website web resources (HTML)
Scripting Web Resources (JScript)
Image (JPG, PNG, GIF, ICO) web resources
XSL web resources (stylesheet)
Web resources from data (XML)
CSS web resources
RESX web resources
WebResource Entity Reference
Example: Transferring several values ​​to a web resource via the data parameter
Example: Importing files as web resources