2022.2

Table Of Contents
UseanIDorclassasselector
Scripts(exceptControlScripts)startwithaquery.TheselectorinthesecondcolumnintheScripts
paneiswhatascriptlooksforinthetemplate.Theselectorcanbeatext,HTML/CSStags,oracom-
binationoftextandHTML/CSStags.
Lookingfortextinatemplateisalessoptimizedoperationandmayimpactoutputspeedsinlongerdoc-
uments.Tospeeduptheoutputprocess,itisrecommendedtouseanIDorclassasselectorinstead.
Thisnarrowsthescopeofthesearchandresultsinaveryfastquery,aselementswithanIDorclass
areindexedbyConnectDesigner'slayoutengine.
ForinformationabouthowtogiveanelementanIDorclass,see"IDandclass"onpage568.
Seealso:"Quick-startascriptforaspecificIDorclass"onpage811.
Targeting text
TextinitselfcannothaveanIDorclass,buttheelementthatcontainsitcan.Thesmallestpossiblecon-
taineroftextisaSpan.TolearnhowtoputtextinsideaSpan,see"Span"onpage625.GivetheSpan
anIDorclassandusethatasthescript'sselector.
Totargettextinabiggercontainer(aparagraph,forexample),changetheFindmethodofthescriptto
Selector and Text,usetheIDorclassofthecontainerelementasSelectorandtypethetextinthe
Textfield.
Tip: DraggingadatafielddirectlytotheScriptspanecreatesascriptwithaclassselector,
withoutaddingaplaceholdertothetemplate.
Tip: Whenyouusethedrag-and-dropmethod(withoutpressingtheALTkey)toinsertvariable
dataplaceholdersintoatemplate,thescript'sselectorisbydefaulttheclassoftheelement-a
SpanorDiv-inwhichtheplaceholderiswrapped.Formoreinformationsee:"Variabledatain
text:scriptsandplaceholders"onpage726.
AvoidDOMmanipulations
TheScriptingAPIoftheDesignerisaverypowerfultooltomanipulateandpersonalizeyourdocument.
ButkeepinmindthatDOMmanipulationcommandslikeappend(),prepend(),before()andafter()are
resourceintensive.
TryavoidingDOMmodifications,especiallywithinloops.Storingthecontentinavariableandappend-
ingtheinformationaftertheloopismoreefficient:thisway,thetemplatewillbetouchedonlyonce.
Page 821