Which is faster Client Script or UI Policy?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2018 12:17 PM
I'm currently looking through onLoad client scripts and ui policies to see if I can trim some fat and speed up my form loads. I have one instance where I want to accomplish a task of setting a couple fields as visible and mandatory depending on another fields value. I don't want the ui policies to be reverse when false so I have two UI Policies that do the opposite of each other, something I could accomplish with one client script.
I know UI Policy is best practice, but in terms of performance is one client script better than two ui policies? If any of the experts out there know or could show me how to test this myself, it would be greatly appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2018 12:29 PM
I haven't benchmarked either one, but my impression is that they are about the same with respect to the response time to the end user
.
The exception would be if you add additional logic to the client script such as an AJAX call to the server. Then the client script would be slower.
EDIT: I'm curious about your requirement to "not reverse" the UI Policy when displaying or hiding a field or fields. Can you tell us aliitle about that? It doesn't affect my advice, but I would like to know about it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2018 12:44 PM
My team has inherited a project from another firm where there's multiple types of records (about 10) all with unique business solutions and fields, but all within one large table. So depending on the type, I want to display a certain field, and hide another. If its a different type I want to do the opposite display rules. The reason I wanted to avoid reverse if false is because if its one of the eight other types its going to execute the reverse.
I ended up going back to reverse if false and setting the ui policy so it only runs on a certain view which those two types share.
Not sure if this made any sense haha but hopefully answered your question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2018 12:48 PM
Thank you for the explanation Dylan! It seems that every important projects has at least one key requirement that is awkward to implement. I consider myself a student of these and I appreciate you sharing it with me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2018 08:23 AM
Dylan, I have always tried to combine things where possible. Its inefficient to download multiple scripts or UI policies versus just 1. Think of the server side executions to queue up the code that then needs to be downloaded to the browser on load, this all takes time. This is definitely important for onChange scripts where multiple on the same field can be "expensive". While I have also heard that UI Policies are best practice, I sometimes chose to implement things in client script instead because of my lack of patience to setup the UI Policies - so much quicker to cut and paste code versus selecting fields.
But all of this said, there are tools at your disposal to help make informed decisions with the little Clock on the bottom right hand corner of your browser. If you click Browser a popup appears showing you the milliseconds it takes to load each component. You can click into UI Policy and Client Scripts to get a breakdown of each script to compare the run time. Hopefully this will help you.
Please mark this post as helpful or the correct answer to your question if applicable so others viewing can benefit.