2022.2

Table Of Contents
ThefirstlineretrievestheHTMLofthepromoblockandstoresitinavariablecalledblock.Tomakethe
codemorereadible,thefieldsfromtherecordarestoredinavariablenameddata.Afterreplacingthe
placeholdersbyvalues,thescriptreplacestheHTMLofthepromoblockwiththepersonalizedstring.
Otherresources
TherearealsomanyresourcesonlinetohelplearnaboutJavaScriptperformanceandcodingmis-
takes.Seeforexample:
l
JavaScriptperformance
l
The10mostcommonJavaScriptmistakes
l
TipsforwritingefficientJavaScript.
NotethatmostresourcesonthewebareaboutJavaScriptinthebrowser,butthegreatestmajorityof
thetipsdo,indeed,applytoscriptsingeneral,wherevertheyareused.
The script flow: when scripts run
WhenConnectgeneratestheactualoutput–letters,webpagesoremails-,itopensarecordsetand
mergesitwiththetemplate.Ittakeseachrecord,onebyone,andrunsallscriptsforit,inaspecific
order,asexplainedbelow.
First all Control Scripts are executed,intheorderinwhichtheyappearintheScriptspane.Control
scriptsdon'ttouchthecontentofthesectionsthemselves,buttheychangethewayatemplateisout-
putted,forexamplebyselectingoromittingsectionsfromtheoutput(see"ControlScripts"on
page838).
Secondly,anyHandlebars expressions are evaluatedinsectionswheretheoptionEvaluate Handle-
bars expressionsisenabled.(OntheResourcespane,right-clickthesectionandselectPropertiesto
findthissetting.)
Then the Standard Scripts are executed,onceforeachsection,intheorderinwhichtheyappearin
theScriptspane.
StandardScriptscanchangethecontentsofthecurrentsectioninatemplate.
Thistypeofscriptmusthaveaselector:text,anHTMLelementand/oraCSSselector(see"Writing
yourownscripts"onpage808and"SelectorsinOLConnect"onthenextpage).
Runningatemplatescriptstartswithlookinginthecurrentsectionforpiecesofcontentthatmatchthe
script'sselector.
Importanttonoteisthatif nothing matches the selector, the script is not executed.
InaPrint context,theStandardScriptsintheScriptspanerunonceforeachsectionandthenforeach
MasterPage(see"MasterPages"onpage462).Next,eachprocessedMasterPageisputbehind
everypagetowhichitshouldbeapplied.
ScriptsareNOTexecutedagainforeverypage.
Page 824