16
Views
4
Comments
Execute script on page load but with server side variables in reactive.
Application Type
Reactive

I'm connecting my application with the New Relic (RUM) monitoring tool. For that I have a javascript that needs to run as soon as possible when the page is being loaded (so from the head of the page). I can do this easily by defining a script and add it to required scripts.

However I want to use site properties in this script (applicationid) to make difference between our environments (development, acceptance, production). So the site property would get a different value in each environment.

I don't see a way to do this in reactive without delaying the execution of my script. Is it possible to do something like this?

2023-04-19 18-38-51
Bas de Jong

I would store the ApplicationID in a client variable, let your execution of your script check if the value is filled, if not, get it from the server, if it is filled. Just use that value and after the first time there would be no more server connection required to get this input parameter.

2018-03-07 11-42-27
Mark Baijens

Thank you for your suggestion. It might be the best possible solution. It still has the disadvantage that the script needs to wait for the retrieval of the server value when the client variable is not set and therefore performance monitoring will be delayed a bit which is not desirable.

2023-04-19 18-38-51
Bas de Jong

True but it will solve most of your problems. In our case we have put this logic in the OnApplicationReady event. 

https://success.outsystems.com/documentation/11/reference/outsystems_language/system_events/on_application_ready/


It will delay the first render of the application but after that you will not experience any delays anymore.

2024-02-27 12-57-22
Sam Rijkers

Given your use case, have you also considered storing that information in cookies or local storage?

- https://www.outsystems.com/forge/component-overview/9847/cookie-management-utils 

- https://www.outsystems.com/forge/Component_Documentation.aspx?ProjectId=4990&ProjectName=local-storage 

Haven't tested these components myself, but it would delay the first render of the application only once (or after the cookies / local storage is reset).

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.