Optimizing Sharepoint Performance With Custom Master Pages And Layouts

The Problem of Slow Page Loads in SharePoint

SharePoint’s default master pages and page layouts often contain excessive markup, images, and web parts that can negatively impact performance. Each additional HTTP request to load a page component delays page render time. Likewise, unoptimized images drive up page weight. The more page weight, the longer pages take to load. Tests show SharePoint publishing pages can easily exceed 6MB in size with 90+ requests, resulting in load times over 15 seconds on average mobile connections.

Issues with SharePoint’s Default Master Pages

SharePoint’s vast library of master pages cater to a wide array of requirements out-of-the-box. However, most contain overlapping and unnecessary markup and assets. For example, Seattle.master includes references to jQuery and other JavaScript libraries used across Microsoft 365 whether a particular site needs them or not. Every script reference forces an extra HTTP request per page. Unused icons, images, and web parts on the master page also get loaded on every page without exception. Streamlining master pages to only include essential assets improves performance.

Problems with SharePoint’s Default Page Layouts

Like master pages, SharePoint’s built-in page layouts favor flexibility over optimization. Web parts like Content Search, Document Libraries, and Media Galleries break up text content with images, scripts, and styling requests. Overuse slows down page loads and hurts user experience. While convenient, productivity web parts often load unused code. Trimming down and properly configuring layouts and web parts simplifies pages. Simple pages load faster.

Optimizing Images and Script References

Image Optimization Techniques

To optimize images on SharePoint pages:

  • Use vector images instead of raster images when possible – vector graphics load faster and scale without quality loss or extra page weight.
  • Enable blob cache on SharePoint to dynamically resize and serve properly sized images – prevents oversized images.
  • Compress images to reduce file size using utilities like TinyPNG without noticeable quality reduction.
  • Set explicit image dimensions to prevent layout shifts and unnecessary reflows as images load.

Consolidating Script References

To optimize script references:

  • Bundle and minify custom scripts into a single file using a utility like UglifyJS.
  • Consolidate multiple references into one Reference.js file.
  • Utilize async and defer attributes to control script loading order and prevent blocking.
  • Explicitly register scripts instead of implicitly loading all site scripts.

Reference consolidation example:



Implementing Custom Master Pages

Creating a custom master page allows full control over the markup loaded on every page. Follow these steps:

  1. Download a base master page like Oslo.master from SharePoint Design Manager.
  2. Delete all unnecessary markup and assets like unused web parts, images, and scripts.
  3. Unregister SharePoint scripts/CSS references explicitly in favor of a single Reference.js file.
  4. Consolidate Styles.css imports into an optimized custom CSS file.
  5. Set page title, headers, footers, and placeholders for breadcrumbs navigation.
  6. Save master page and upload to Master Page Gallery in SharePoint.
  7. Set as default master page in site settings.

This produces a clean starting point with only essential page markup. Further customizations can build on this foundation without reintroducing unnecessary extras.

Creating Efficient Page Layouts

Page layout optimization best practices include:

  • Simplify layout structure - Remove columns, unnecessary divs, and wrapping elements to flatten layout.
  • Delete unused web parts - Get rid of irrelevant web parts dragging down performance.
  • Limit web part scope - Bind event handler registrations and logic to configured scope.
  • Configure web part properties - Set properties to reduce entries fetched, limit images, etc.
  • Inline critical CSS - Embed CSS for above-the-fold content directly in page markup.

Laying out content in a single column without extraneous containers, styling, and web parts keeps pages simple. Complex, nested page structures introduce more ways for things to go wrong performance-wise. Target only essential areas in need of enhancement instead of including a suite of irrelevant web parts.

Example: Optimizing the Content Search Web Part

When adding a Content Search web part:

  • Scope search to a specific site section in properties.
  • Reduce maximum items per page.
  • Choose specific fields to return rather than entire objects.
  • Disable trimming characters to prevent reflow.
  • Show no result preview images.

This displays focused content efficiently without expensive metadata lookups and unnecessary media embeds.

Setting Up Content Delivery Networks

A content delivery network (CDN) serves static assets from globally distributed caching servers. Using a CDN offloads resource delivery from SharePoint. Resources load faster from nodes closer to visitors. Enable CDN support in SharePoint Online as follows:

  1. Navigate to the SharePoint Admin Center.
  2. Under Policies, choose "CDN policy".
  3. Select option "Use the Public Office 365 CDN" to enable the feature.
  4. Check the box for each type of library to serve from CDN.
  5. Save changes.

Uploading custom scripts, images, and stylesheets to document libraries allows serving them from the CDN. Configure master pages and layouts to reference the CDN URLs. Visitors now load static assets from nearby CDN servers. Using a CDN also improves caching since assets remain in nodes closer to users between page views.

Analyzing Page Load Performance

Analyze SharePoint page load performance before and after customizations using browser developer tools like Chrome DevTools:

  1. Open the SharePoint page in Chrome and open DevTools.
  2. Reload the page with DevTools open, stopwatch in hand.
  3. Note the total load time displayed.
  4. In the Network tab, look at total requests, transferred data size, and resource details.
  5. Check page speed insights for optimization suggestions.
  6. Identify the largest and slowest resources causing bottlenecks.
  7. Compare load times and network requests before and after customizations.

Measuring provides numbers to back up perceived changes from optimizations. Significant drops in load times, page weight, blocking requests, and other metrics demonstrate the impact of customizations.

What to Monitor

  • Page load time
  • Total page weight
  • Number of requests
  • Time to first byte
  • Slowest resources
  • Largest resources by payload size

Mastering web performance analysis empowers data-driven optimization decisions rather than guesses. Many tools integrate with browser developer tools to further drill into SharePoint load metrics.

Continually Monitoring for Regressions

An optimized SharePoint site easily degrades over time as updates roll out or new customizations pile on. Continually monitoring performance identifies regressions before users complain. Many tools automatically track metrics over time. These include:

  • Chrome User Experience Report - Tracks real user performance data from Chrome users at scale.
  • WebPageTest - Automates loading pages from test locations worldwide and compares results.
  • SpeedCurve - Performance monitoring with configurable tests, reporting, and alerting.

Set performance budgets so tools automatically alert on threshold breaches before problems surface. For example, set an 8-second load time budget and get notified if page load regressions start trending longer. This way additional weight gain may get addressed before pushing average load times into double digits.

Ongoing optimization combined with continual monitoring ensures fast, consistent page load times even as sites evolve.

Leave a Reply

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