Hello Experts,
I’m writing this post because of the MSDN article regarding new CRM form rendering engine and its effects on JavaScript development (https://msdn.microsoft.com/en-us/library/gg328261%28v=crm.8%29.aspx). We may find the following information there:
If you have code that depends on another library to be fully downloaded and initialized, the most straightforward approach is to combine both libraries within a single JavaScript web resource with your code below the library code. A more sophisticated approach is to use libraries such as head.js or require.js to control how the separate libraries are loaded.
Because of above mentioned information I have prepared some tests. I’ve created 2 JavaScript web resources. The first one, named Common.js was over 4 MB library. Second one – Account.js contained implementation of Account entity form event handlers (OnLoad & OnChanged) and was using Common.js library for some logic.
I’ve attached both libraries to Account form and started testing. Results of my actions are described below:
- Both libraries have been loaded in parallel as it is described in the article (of course - Account.js was loaded much faster then Common.js).
- CRM form does not present us its UI until both libraries was 100%-loaded (instead it shows us “loading business logic” information).
- The first event handled by custom code (form onLoad) took place when all the form-attached libraries had been loaded.
I have tested many different combinations (entities: Account, Contact, Quote, different network throttling’s, etc.) and I wasn’t able to make Account.js code running on CRM form without loading all the forms-related libraries (in my case – it was over 4MB Common.js).
Of course – form rendering legacy mode was disabled during my tests. I tested both CRM Online and on-premise 2016 SP1 organizations.
My question is – why do we really need require.js of single file implementation (as MS describes it above)? It looks like CRM UI rendering engine presents us CRM forms and runs forms event handlers only when all the form-related libraries are loaded.
Any specific scenarios? Entities? Components?
Kind regards.