How to remove Kendo.all.min.js from your Sitefinity site

by Vesselin Vassilev


Posted On Feb 2, 2016


If you have upgraded a Sitefinity site to version 7.3 or higher you may have noticed that, all of a sudden, the javascript footprint on your pages have increased with approximately 1MB. That's a lot of new and probably unwanted/unneeded javascript on your page.

The cause for this in many cases is the inclusion of the built-in Search Box widget (web forms). 
Yes, a small widget like the SearchBox can include the entire Kendo UI javascript library.

Since Sitefinity 7.3 the search box has a new functionality called Suggestions (or autocomplete) that is turned on by default. It uses the Kendo UI autocomplete component, so they decided to include the entire 1MB javascript library.

The first thing anyone would try is to disable the search suggestions by editing the SearchBox widget and going to its Advanced settings and setting DisableSuggestions to True as below:

DisableSuggestions

Unfortunately this does not prevent the kendo.all.min.js from loading. 

The next thing to do is to actually check the html code of the default SearchBox widget.
If you scroll down a bit on the above screen you will see the LayoutTemplatePath property which points to:
~/SFRes/Telerik.Sitefinity.Resources.Templates.PublicControls.SearchBox.ascx

This means we need to open the Telerik.Sitefinity.Resources.dll with JustDecompile and find the above embedded resource. 

The code is pretty simple, yet powerful (loads a lot of stuff ;))



As you can see there is a reference to jQuery and to KendoAll libraries. 

To get rid of the the KendoAll library the process is pretty simple - copy the code from above, remove the reference to KendoAll library and save it as a user control (.ascx) somewhere in your project, e.g. WidgetTemplates/SearchBox/SearchBox.ascx

Finally, edit the SearchBox widget, go to its Advanced settings and put the full path to your custom template in the LayoutTemplatePath property, e.g.
~/WidgetTemplates/SearchBox/SearchBox.ascx

Save and then publish and voila - you've got 1MB less javascript on your page.

Of course if you want to use the search suggestions feature you would have to leave the above as it is.

Copyright © Sitefinity Development