Silverlight Client Object Model: cache referenced client assemblies

Those who follow me on Twitter already noticed I am at the SharePoint Connections 2010 Autumn conference in The Hague (The Netherlands) right now. I’ve attended a few very interesting sessions and I will probably go deeper into some of the topics over the following weeks. However there was one small remark mentioned during one of the sessions, that I think everyone who uses the Silverlight Client Object Model should know about.

As you all know, when programming against the Silverlight Client Object Model, you have to add a reference to the following assemblies:

  • Microsoft.SharePoint.Client.Silverlight.dll
  • Microsoft.SharePoint.Client.Silverlight.Runtime.dll

When you build the Silverlight package, both assemblies are also included and will add about 407KB of extra size to the xap file. For most small Silverlight applications that you create, this means a multiplication of the size by a factor 10 or more. This also means more bandwidth usage and longer loading times for the user.

A solution to this problem is described by Paul Stubbs: “A better option is to dynamically load these assemblies at run time. This enables the browser to cache these common files, reducing your application size and the load times while increasing the performance of your applications.” Both assemblies are already pre-packaged and you can find them in\14\TEMPLATE\LAYOUTS\ClientBin as Microsoft.SharePoint.Client.xap. For the actual implementation I redirect you to the article itself, last paragraph: “Dynamically Loaded Client Object Model”.

Credits go to Paul Stubbs for the implementation and to Andrew Connell for mentioning it during one of his sessions. Please share this knowledge amongst your colleagues to reduce loading times and to raise the positive perception that users have about Silverlight (and SharePoint).

Edit: It might be a good idea if Microsoft placed this file on their CDN.

Licensed under CC BY-NC-SA 4.0; code samples licensed under MIT.
comments powered by Disqus
Built with Hugo - Based on Theme Stack designed by Jimmy