Naming Convention –
- Try to keep variable and function name short and meaningful.
- Make the naming convention consistent. Use either Pascal or Came case, but be consistent with it.
In a form, you can have up to 50 js files but it doesn’t mean you should have 50 small files in a form. try to keep that count minimum.
Refer Attribute Name –
What NOT to use –
- Do not use getElementById or any other DOM manipulation techniques. They are NOT supported and may not give the expected result. Instead, use Xrm.Page Object model.
- Do Not expand all the tabs on form load. Tab loads its resource when it is expanded for the first time. Instead, keep them collapsed and expand only those are mandatory.
- Do NOT use parenthesis for the function name. like this
Few more Important Points –
- If you have code that only supports OnChange events for fields or the OnSave event, make sure to set the script library with the event handler for those events instead of the OnLoad event. This way loading those libraries can be deferred and increase performance when the form loads.
- Avoid using form scripts in the OnLoad event that hide form elements. Instead, set the default visibility options for form elements that might be hidden to not be visible by default when the form loads. Then, use scripts in the OnLoad event to show those form elements you want to display.
I hope this helps. These are based on my experience and below links.
Happy Dynamics’ing !!!