A main turn-off for K2 Smartform users is slow loading forms. If you have non-functional requirements that have page loading times, you especially will need to make sure your forms are quick and snappy. If you have already worked on a number K2 Smartforms, you will no doubt be familiar with what some of our users have dubbed the “K2 Spinner.” This is a result of browser pre-loading technology. By using the following tips you can massively increase the performance of your K2 Smartforms, particularly if you are upgrading from a version pre-dating 1.0.6.  

Making use of the Initalized rule.

The When Form is Initialized Rule is a Form/View rule which executes immediately after the When Form is Initializing has completed. It was introduced in SmartForms version 1.0.6. So why is this rule significant to performance times? Well, the “K2 Spinner” is rendered over the form while the rules in When Form is Initializing are executed. If you have a rule which is executing a slow query within, or are using the wrong execution type (more on that later), then the spinner will remain until those rules have finished executing. Let’s take a look at an example. I am using the AdventureWorks2012 sample database which contains a Person table with about 20k rows of data. I have created a SmartObject from that table and then built a list view on that SmartObject and put that into a form.  In addition I also created an Item view and placed that on the form and loaded it up: Blog - Tips for K2 smartforms performance - Image1 This actually took about 30 seconds before the form was interactive! Now I stopped the list method executing in the When Form is Initializing rule and moved it to the When form has Initialized:Blog - Tips for K2 smartforms performance - Image2 The form was interactive in under a second and the list view continued to execute via an ajax call.  Allowing the user to start filling in the form while the slow query is executing. An extreme example to illustrate the point, but you can see the impact of utilizing this rule. The second most useful tip I can give is to choose the correct rule execution type.  We have covered execution types in detail in a previous blog: K2 SmartForms Best Practice so I will be to the point here. Where possible – and most importantly in the When Form is Initializing rule try to avoid using the one after another execution.  This means the first action executes, waits to complete, and then executes the next one.  Check out this link for a detailed guide to execution types. And the last quick tip I can give is when using controls such as drop down lists and pickers, they will automatically insert rules into the When Form is Initializing rule. Move these rules to the When Form is Initialized rule and set them to run asynchronously (unless you’re using cascading dropdowns) and you will improve your load times even more!