• Publisert
  • 1 min

Reducing number of request and page size when using Web Parts in EPiServer

The EPiCode.WebParts.Core framework supports editing Web Parts in most browsers. This is done by using Microsoft.Web.Preview.dll and a ScriptManager as mentioned in this post. The cost is 5 extra requests and approxemiatly 141 ekstra KB in total. The .Net framework also adds some script blocks directly into the page like this:

<script type="text/javascript">
var __wpmExportWarning='';var __wpmCloseProviderWarning='';var __wpmDeleteWarning='';
<script type="text/javascript">
__wpm = new WebPartManager();
__wpm.overlayContainerElement = null;
__wpm.personalizationScopeShared = true;
var zoneElement;
var zoneObject;
zoneElement = document.getElementById('ctl00_FullRegion_uxStartPageBottomZone');
if (zoneElement != null)
    zoneObject = __wpm.AddZone(zoneElement, 'ctl00$FullRegion$uxStartPageBottomZone', false, false, 'black');
    zoneObject.AddWebPart(document.getElementById('WebPart_wp343456060'), null, false);
    zoneObject.AddWebPart(document.getElementById('WebPart_wp888026939'), null, false);
    zoneObject.AddWebPart(document.getElementById('WebPart_wp1609364609'), null, false);
    zoneObject.AddWebPart(document.getElementById('WebPart_wp1062968821'), null, false);

This applies to both Web Part editors and visitors to your site. Unless you are using your ScriptManager for other purposes this is not wanted for visitors!
The upgraded  EPiCode.WebParts.Core (Version >= 2.0.2237.0) resolves this.

Follow this guide to reduce page size and requests for vistiros.

  1. Install latest EPiCode.WebParts.Core from EPiServer NuGet
  2. Replace your <asp:ScriptManager with <epicode:ScriptManagerLowUiImpact
  3. Make sure you are using <epicode:EpiWebPartManager and not <asp:WebPartManager