Friday, October 29, 2010

Reducing the XAP size

The whole reason for keeping XAP size small is so that your application loads as quickly as possible. This is important as a larger XAP can take extra seconds to load, which can be long enough for your users to leave your site and not come back.
Make sure that you worry about the XAP size from Day one of the project and make sure that its not too late to think about this.
There are many ways to reduce the XAP size. I have pointed out few of the points below:
Ø  Remove all the Images from the Silverlight application and place it on the WebApplication. This way you will be able to reduce the load on the XAP.
Ø  Use application library caching (it's just a project setting), by doing this all signed assemblies will be stored in separate ZIP files, this means: first time the user starts the application he will have to download all the content anyway, next time he will have to download only the main XAP file and the rest of ZIP elements will be retrieved from the browser cache, this solution is interesting if you share that signed assemblies between different Silverlight Applications.

Ø  Configure your assembly file to be included in the application library caching.
Ø  If you are using any resource files like static XML, etc. Make use of the Isolated Storage. This won't enhance the first load of the application, but in subsequent downloads you can check whether the resource is already available on the client local storage and avoid downloading it from the server. Make sure that you have a version number with the file name so that you download the latest file and delete the older ones. Also make sure that you have enough storage size as Silverlight allows only 1 MB initial size. If you need more space extend the storage size.

Ø  Reduce the code size by using the patterns and practices like MVVM, Light MVVM, Prism, MEF, etc.
Ø  Obfuscate your code.
Ø  Load assemblies on Demand, this trick are possible due to the Silverlight API, that allows us to load assemblies into the AppDomain. We need to download one using simple WebClient, load it and use Reflection to use its types and resources. Although this is tricky and kind of obsolete, one can find it interesting and implement it on his/her own.
Ø  Create nice looking and professional SplashScreen that will reduce the bad experience from downloading big xap package.

Thursday, October 28, 2010

Introduction

This blog is mainly to share the knowledge that I get during the development using Silverlight. There will be a post made every week on any of the interesting topics. If there is any topic that you want me to specify, please post your comments so that I can have a post on that topic in later weeks.



Hoping to get all your support!.