|
Managing scriptsChanging the order of executionWhen a record set is merged with a template to generate output, all scripts are executed once for every record in the record set, in the order in which they appear in the Scripts pane at the bottom left. The order in which scripts are executed is particularly important when one script produces content that contains a selector for another script. If the other script has already been executed, it will not run again automatically. So, scripts that produce content that contains one or more selectors for other scripts, need to come first. To change the order in which scripts are executed:
Control scripts are always executed first, regardless of where they are in the Scripts pane. They can not be excluded from execution for a specific context or section, using the execution scope of a folder; see Execution scope. What you can do is disable the script or the containing folder; see Enable/disable scripts. Script foldersScripts can be organized in folders. Why would you do that? For three reasons:
To make a new folder on the Scripts pane:
It may be helpful to put scripts that have an effect on the same context or section in one folder, because you can set the execution scope of scripts per folder (see: Execution scope). Control scripts are always executed first, regardless of where they are in the Scripts pane. They can not be excluded from execution for a specific context or section, using the execution scope of a folder; see Execution scope. What you can do is disable the script or the containing folder; see Enable/disable scripts. Execution scopeA particular script may be used in one context or section, but not in other contexts or sections. Nevertheless, when processing the template, the Designer tries to find the selector of each script in all contexts and sections – unless the script is located in a scripts folder for which the execution scope has been set to the relevant contexts or sections. So, setting the execution scope of a folder saves processing time. To change the execution scope of a script:
Control scripts are always executed first, regardless of where they are in the Scripts pane. They can not be excluded from execution for a specific context or section, using the execution scope of a folder; see Execution scope. What you can do is disable the script or the containing folder; see Enable/disable scripts. For more ways to optimize scripts, see Optimizing scripts.
Enable/disable scriptsA disabled script will not run at all when the template is merged with a record set to generate output. Disabling script execution in certain contexts or sections helps with performance, since scripts normally run, whether or not their placeholder or selector is present in your template. It is highly recommended to disable any script that is not relevant to specific sections or contexts. When you disable a folder, all scripts in the folder will be disabled. To enable or disable a script or a folder:
For more ways to optimize scripts, see Optimizing scripts.
Import/export scriptsScripts can be exported - one at a time - for use in other templates. To do this:
To import a script in a template:
Files that a script may refer to, such as images, snippets and fonts, are not exported or imported together with a script. Test the script to make sure that all files are present in the template and that the script's selector matches something in the content of the template; see Testing scripts. |
|