2022.1

Table Of Contents
This topic presents a number of other ways to speed up script execution by optimizing the
scripts.
Use an ID or class as selector
Scripts (except Control Scripts) start with a query. The selector in the second column in the
Scripts pane is what a script looks for in the template. The selector can be a text, HTML/CSS
tags, or a combination of text and HTML/CSS tags.
Looking for text in a template is a less optimized operation and may impact output speeds in
longer documents. To speed up the output process, it is recommended to use an IDor class as
selector instead. This narrows the scope of the search and results in a very fast query, as
elements with an ID or class are indexed by Connect Designer's layout engine.
For information about how to give an element an ID or class, see "ID and class" on page667.
See also: "Quick-start a script for a specific ID or class" on page921.
Targeting text
Text in itself cannot have an ID or class, but the element that contains it can. The smallest
possible container of text is a Span. To learn how to put text inside a Span, see "Span" on
page733. Give the Span an ID or class and use that as the script's selector.
To target text in a bigger container (a paragraph, for example), change the Find method of the
script to Selector and Text, use the ID or class of the container element as Selector and type
the text in the Text field.
Note
When you use the drag-and-drop method (without pressing the ALT key) to insert
variable data into a template, the script's selector is by default the class of the element - a
Span or Div - in which the placeholder is wrapped. For more information see: "Inserting
variable data directly (drag-and-drop)" on page847.
Avoid DOM manipulations
The Scripting API of the Designer is a very powerful tool to manipulate and personalize your
document. But keep in mind that DOM manipulation commands like append(), prepend(),
before() and after() are resource intensive.
Page 934