How to improve the loading times of K2 Smartforms

by | Mar 1, 2016 | BlogPosts, K2, Tech Tips | 0 comments

Overview

One of the main ‘turn-offs’ for users of K2 Smartforms is slow loading forms; if you have non-functional requirements with page loading times, you will need to make sure your forms are quick and snappy.

If you have worked on a number of K2 Smartforms you will no doubt be familiar with what some of our users have dubbed the “K2 Spinner” which is a result of browser pre-loading technology.  By using the following tips you can massively increase the performance of your Smartforms especially if you are upgrading from a version pre-dating 1.0.6.

 

Making use of the Initialized 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?

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 here, or are using the wrong execution type (more on that later). then the spinner will remain until those rules are 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 created a SmartObject from that table, 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:

2016-02 Blog - Improve K2 Smartforms loading times - Image 1

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:

2016-02 Blog - Improve K2 Smartforms loading times - Image 2

The form was interactive in under a second and the list view continued to execute via an ajax call, therefore allowing the user to start filling in the form while the slow query was executing. It’s an extreme example to illustrate the point, but easily demonstrates 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 straight to the point here…

Wherever possible – and most importantly, in the When Form is Initializing rule – try to avoid using the one after another execution.  This means that the first action executes, waits to complete, and then executes the next one.  Check out the K2 best practice for Smartforms blog for a detailed guide to execution types.

My final quick tip is this: when using controls such as drop down lists and pickers, be aware that 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!

Subscribe now for regular updates on new blog releases:

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *