Hey all,
I’ve got a template in production that is used to generate printable PDFs. The template has evolved over the years and become rather unwieldy, most likely due to the number of print sections combined with the number of scripts. My understanding is that every script is executed on a per print section basis, per record from the data mapper. This ultimately has a knock on effect on the time taken by WorkFlow to generate a PDF.
I’ve been looking for ways to improve our situation, and recently discovered this: https://help.objectiflune.com/en/pres-connect-user-guide/2020.2/#designer/Scripting/Optimizing_Scripts.htm
So after reading through it, I’ve discovered two things:
ID/Class selectors are generally faster than text selectors for scripts. This is massive, as I currently have over 800 individual text selector scripts. (This combined with over 300 print sections is where I believe I’m losing a large portion of efficiency.) So I can slowly work through my text selectors and their associated text within the template, and replace.
Additionally, multiple selectors can be handled in one script, rather than a script for each. This means I can work to massively reduce the number of scripts in the template, reducing the execution overhead on a per print section basis.
I’m trying to combine both these steps for improving efficiency in one sweep, but I’m snagging on testing replacing text selectors with ID selectors. I’ve created a very simple mock up, to show an example. My text selectors are updating perfectly, but I’d like to know if I can improve them further by swapping to an ID selector as mentioned above.
This is my example setup: (Image shows in preview, unsure if it’ll persist once posted.)
Is anyone able to comment on line 6 of my script, if I can use ID based selectors like this, rather than the text based selectors above?
Additionally; based on the same vein, would anyone be able to advise if a similar setup would be possible for control scripts, with logic for individual print sections contained in a single script instead of a control script per print section?
Thanks,
Jamie.