I have noticed you can either define the script required for your JavaScript at the screen level in the "Required Scripts" section, or you can use the Client Action "Required Scripts" to call it inside your action.Is there a best practice on when you should use one over the other and is there an advantage to using the client action over describing it at screen level? (Because I would assume defining it at screen level would make it more reusable)Thank you in advance
Hi @Isaac Wangombe ,
i think putting the scripts you need in the required scripts section of a screen or block is the default way of doing this. It is what the documentation suggests you do, and if you look at components made by OS, like the default layout blocks, or the Outsystems UI blocks, that's what these also do.
The reasons i could imagine for doing it in a client action instead :
see this section on javascript in the documentation, with this chapter on using scripts.
Or see this learning material.
Dorine
Hi Isaac Wangombe,
It is not advisable to use javascript in screen level or Actions level until unless it is really necessary.
If we use a heavy javascript on a screen level it may create performance issues.
Client Action level javascript can access the screen HTML elements and also we can pass the dynamic ID.
We need to make it lighter and re-usable scripts with lesser dependency of other components.
Hope it helps.
Hi @亗『ARAVIND』亗 ,
I'm not sure I understand this answer, do you mean it is advisable to have large scripts under the script section as opposed inside a javascript node ? Agree, but I think Isaac is already doing that. Or do you mean someting else ?
I think his question is about how to indicate that you need a given script in a given screen or block.
Hi Dorine,
I was saying that, using js unnecessarily without experiencing platform widgets may leads to performance issues.
Thank you so much for your response Aravind,So when using the scripts, it is more advisable to use this:
As opposed to this:
Yeah, require scripts for Online JS URL.Second option is offline.
Thank you @Dorine Boudry,This is exactly what I was wondering