I was reading this blog post from the CRM Lady
Turbo Forms in Microsoft Dynamics CRM 2015 (v7.1.0)
The article points to some good resource learn more about the new turbo forms.
The article from the CRM Team has a wealth of interesting information and lots of healthy warnings for you
Microsoft Dynamics CRM Online 2015 Update 1 – New Form Rendering Engine
What are the new turbo form
Microsoft have been doing lots of tinkering how the CRM forms are rendered. This graphic shows the effect
// // // // // //
When I saw the graph above my first thoughts were
- WOW, Awesome
- How did they get such a dramatic improvement
- Will this break my customizations
How did Microsoft Improve loading times
I will quote the article
There are 2 main changes that have been made: loading process of the form, and handling of cache.
The article indicates they have moved to parallel loading and are caching more data.
Hmmmm Parallel Javascript loading
The increased form loading is great but parallel loading can have some downsides. I first came across Javascript parallel loading in CRM 2011 rollup 12, you can read about here
- CRM 2011 – Things learnt when reviewing Javascript code on form loads
- Intermittent errors with JavaScript personalization post UR12- Library is undefined
- CRM 2011 Polaris Asynchronous Javascript Loading
To speed up form loading in CRM 2011 they switched to parallel loading and the result meant lots of Javascript methods suddenly stopped working. The reason for this was because one Javascript file was calling a method on another javascript file. This worked when the Javascript files were loaded in an order but when you load them all at once sometimes one Javascript file tries to call another dependant Javascript file which is still loading.
So suddenly lots of Javascript errors appeared and all developers had to write a Javascript wait file, like CRM MVP Scott Durow talks about in this article
This is a significant change and could cause lots of errors if you have Javascript code in your OnLoad functions which call other Javascript files.
I noticed a new section appeared in the mdsn article Write code for Microsoft Dynamics CRM forms
Manage library dependencies
As a performance optimization, Microsoft Dynamics CRM forms load JavaScript web resources asynchronously and in parallel. This means that the order in which the libraries are configured for a form does not guarantee that a library will be fully downloaded and initialized before another library might attempt to use one of the objects defined in it.
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.
Is Parallel loading good or bad
There is a quote in blade runner
Replicants are like any other machine. They’re either a benefit or a hazard. If they’re a benefit, it’s not my problem.
Upgrading to CRM 2015 SP1 could cause big problems to Javascript customizations. It’s good practise to split up your Javascript code to separate files to make it reusable and maintainable but now Microsoft are recommending we put everything in one file. This could turn out to be one big massive Javascript file, which is ok for performance but maintaining and working with this file is difficult.
This change could catch many CRM developers out because the errors are intermittent, sometimes the javascript files will have loaded in the correct order and work.
It will involve developers writing Javascript code which waits until all the Javascript files load which will cancel out any benefits from parallel loading.
It could be seen as an opportunity to restructure Javascript code to have a self contained loading script and then move other Javascript functions to OnChange events. This would be a double win of increased loading time due to parallel loading and running less code.
You can use Legacy form loading style
There is a system setting which contains a global setting to control which form loading style you use.
It’s a great idea for Microsoft to put this in because the new speedier form loading code might take some while getting use to it. When CRM 2011 polaris release came it, it caused a raft of blog posts because CRM Javascript customizations suddenly stopped working.
Good analysis!. One more time, the performance wins over reusable coding! It doesn’t look like logical by Microsoft to recommend the utilization of certain use of development patterns, and later to dissuade their use in favor of best performance.
LikeLike
Good job raising awareness of this. Actually Web Resource JavaScript has been loaded in parallel since CRM2013 (and briefly in CRM2015 UR12-UR14). CRM2015 SP1 doesn’t actually change the loading behaviour and it is the still the same as I describe here – http://community.dynamics.com/crm/b/develop1/archive/2013/11/02/crm-2013-script-loading-deep-dive
See more here – http://community.dynamics.com/crm/b/develop1/archive/2015/05/24/turbo-forms-get-your-javascript-ready-for-crm2015-update-1
LikeLike
something is different, I never had a problem with calling functions from other files, then I applied the update 1 and I am getting errors everywhere. Mainly due to us using a common javascript file called from just about every entity in the system!
LikeLike
To load the forms quicker it loads them all at once. This means if one of your Javascript files has a dependency on another file, you need to either
put the JavaScript for the form loads into the same JavaScript file (not great for reuse)
Load the JavaScript files in order
LikeLike