Well there are tips to be found on the internet, but much of what you'll find is outdated. Some say that recompressing the XAP file with something like WinRAR on its "best" compression setting will help. But that was in the Visual Studio 2008 / Silverlight 2 days. Now if you're building a Silverlight 4 app in Visual Studio 2010 it's already going to be compressed about as heavily as is possible.
So I'm going to talk about other effective techniques that will help you today.
Read more about this feature from Microsoft.
3.) If you have a need for just one of these controls below, then download and use it rather than including the entire System.Windows.Controls assembly:
I ripped those controls out of the Silverlight SDK a couple weeks ago, and created individual projects out of them. If you only needed the Grid Splitter, for example, then you could save around 60 KB by adding it to your project instead of the entire System.Windows.Controls.dll.
4.) Set up content expiration in IIS. So far we've just been concentrating on the XAP file itself. It's easy to forget about server configuration. Just like Tip #1, this is all about improving the experience for repeat visitors (and reducing server load of course).
In IIS7, follow these steps:
- Browse to the ClientBin folder (or wherever you XAP file(s) are stored)
- Open "HTTP Response Headers"
- Click "Set Common Headers..."
- Check "Expire Web content" and select "After" some time. Sometimes I'll set it for 1 hour, or sometimes 1 day depending on how important it is that the application remains up-to-date.
1.) XAPs Minifier Visual Studio 2010 plug-in
As mentioned in tip #2, sometimes when working with a Silverlight app you might have an assembly reference that has been set to "Copy Local" when it doesn't need to be. This is easy to overlook when working with a large Silverlight app composed of multiple projects. The XAPs Minifier is intended to remove any redundant or unnecessary assemblies.
2.) ComponentOne XAPOptimizer
The XAPOptimizer is not free, but it does take optimization to another level. It goes beyond assembly removal. It'll dig into every assembly through reflection and actually detect unnecessary classes, resources and entire sections of XAML. It's also configurable in case it makes a mistake you can actually specify what to remove and save your settings. On top of this, it'll optionally obfuscate your application, making it hard to reverse-engineer.