Tuesday, November 26, 2013

Optimize the size of xap file an easy way.

Your silverlight projects .xap file is getting bigger, this happens because of some assembly issues. And ofcourse there are some ways to optimize it.

http://blogs.telerik.com/miromiroslavov/posts/10-09-15/5-ways-to-reduce-your-xap-size.aspx

The above article shows few popular ways to reduce the size of xap file.

I had a xap file what was almost 4 mb in size. so I decided to do some optimization.

First thing i did is to remove all unused references and control references. fortunately resharper has some good feature on this. I right clicked on the project and selected “Optimize Reference” and removed all unnecessary references.

Now my xap file is reduce to 1.6 mb. that is almost 200% reduced. awesome.

image

Next there are some option for assembly caching, if you go you the silverlight tab of the project you would see that there is a checkbox for “Reduce XAP size by using…….” Just check it and recompile it. 

image

Next what happen is all the other assemblies that is been used are zipped and added in client bin folder. and reduce the xap file size to negligible.

image

But that does not help that much I guess as the total is still about 1.6 mb. any its a feature and we can used it.

Until next time cheers!.

Update: Checkout this kick ass article to get crazy on size reduction

http://blogs.telerik.com/xamlteam/posts/08-05-13/increasing-the-compression-ratio-of-the-xap-files.aspx