2022.1

Table Of Contents
results.html(block);
The first line retrieves the HTML of the promo block and stores it in a variable called block. To
make the code more readible, the fields from the record are stored in a variable named data.
After replacing the placeholders by values, the script replaces the HTML of the promoblock with
the personalized string.
Other resources
There are also many resources online to help learn about JavaScript performance and coding
mistakes. See for example:
l JavaScript performance
l The 10 most common JavaScript mistakes
l Tips for writing efficient JavaScript.
Note that most resources on the web are about JavaScript in the browser, but the greatest
majority of the tips do, indeed, apply to scripts in general, wherever they are used.
The script flow: when scripts run
When Connect generates the actual output letters, web pages or emails -, it opens a record
set and merges it with the template. It takes each record, one by one, and runs all scripts for it,
in a specific order, as explained below.
First all Control Scripts are executed, in the order in which they appear in the Scripts pane.
Control scripts don't touch the content of the sections themselves, but they change the way a
template is outputted, for example by selecting or omitting sections from the output (see
"Control Scripts" on page954).
Then the Standard scripts are executed, once for each section, in the order in which they
appear in the Scripts pane.
Standard scripts can change the contents of the current section in a template.
This type of script must have a selector: text, an HTML element and/or a CSS selector (see
"Writing your own scripts" on page918 and "Selectors in Connect" on the next page).
Running a template script starts with looking in the current section for pieces of content that
match the script's selector.
Important to note is that if nothing matches the selector, the script is not executed.
Page 938