How to stop RadListView bloating your page

March 05, 2015
Most of the "List\Master" widgets in Sitefinity Webforms use the telerik:RadListView control, and don't get me wrong, it's a GREAT server-side control to use.  Way nicer to code with than the standard asp:Repeater.

Lets look at the default events definition
<telerik:RadListView ID="eventsList" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">

So be default across the system they ALREADY stop all stylesheets from coming down.  Which is great right, you don't want any default styling, the control is basically a repeater.

The PROBLEM though is that there are clientside scripts that come down...a lot of them :)  It's more visible when you enable the CDN from the backend, but with just one single RadListView on your page you get.
- Core.js
- Custom jQuery.js
- RadListView.js

Bunch of beefy client scripts coming down which you will never use, and actually it'll also throw some markup at the bottom of your page to register the client objects as well.

Here's the fix :)

<telerik:RadListView ID="dynamicContentListView" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false"  EnableEmbeddedScripts="false" RegisterWithScriptManager="false">

If you just set EnableEmbeddedScripts to false you'll get script errors on the page because the script manager is putting the above mentioned markup\code to register the widget.  So that's where you need to tell the scriptmanager to just NOT register this guy. boom, on all my pages where I don't have any RadControls I no longer have 2 versions of jQuery plus other bloat coming down.

Image Description

Steve McNiven-Scott

Best\Only Blogger on this site. Therefore defacto blogger of the year Award Winner.