JavaScript Upgrade Strategy #11: Configuration vs. Code

Starting with Dynamics CRM 2011, we have the ability to hide form elements (fields, sections, tabs) by using either JavaScript or by setting the Visible by Default property using the properties dialog for each individual form element.

If you are upgrading your JavaScript from Dynamics CRM 4.0, you probably have code in your OnLoad event that will hide one of these form elements. While this is a 100% valid and supported development practice, you may find that hiding a form element using the configuration dialog offers better performance than hiding an element using JavaScript.

This is mostly due to the way in which the form is created and displayed to the user. In some cases, you may actually see the form display in entirety, then see elements disappear.

So, I consider it a best practice to always use configuration over code in this particular case, again, for performance reasons.

If the form involves heavy use of the hide/show technique, I prefer to hide all of the “variable” elements, then use JavaScript to show what is required, depending on whatever startup value I use to make the decision to hide or show elements.

That being said, you should always test both variations because your experiences may differ depending on your configuration and environment.