Don't look at my SWC size

If you want to use a library in your Flex project, distributed as a SWC file, you should not look at the SWC file size as any indication of how much your compiled application will increase in size. If you want to know how much size overhead the library imposes, look at the compiled release version of your app (Click on Export Release Build button). Even then, it will depend on how much of the library you are using.


If you want to use a library in your Flex project, distributed as a SWC file, you should not look at the SWC file size as any indication of how much your compiled application will increase in size. If you want to know how much size overhead the library imposes, look at the compiled release version of your app (Click on Export Release Build button). Even then, it will depend on how much of the library you are using.

I've heard at least twice people complaining that Mate's SWC was over 600KB, thinking that using Mate in their projects would be prohibitive because it would make their app's file size to be over 600KB. It's easy to see that is not true by looking at any of the examples in the website. While they are all small apps, none of them is over 350KB, the largest ones being those that have the most embedded assets such as images. (Since then, Mate went on a strict compiler diet, see last paragraph).

This is either a misunderstanding of how things work or a confusion between SWC and RSLs (Runtime Shared Libraries), which are actually loaded at runtime and therefore will effectively increase the total amount of data the app needs to run. When "Merging the library into the code" (a setting in the Flex Build Path screen in Flex Builder), the compiler will be smart enough to leave classes that are not used in the app out of the final SWF. This is the default setting whenever you add a SWC to your library path. In our tests, using Mate increases your SWF file size by around 10 to 20KB (again this depends on what you use of Mate).

You could, also, export the SWC file separately, making it an RSL. In this case, the whole library is exported, even if you there are parts you don't use. Using this setting is good when you want to share this library among different Flex apps because the library is removed from the final SWF file, and loaded separately so that the browser can cache it. In this case as well, the library SWF that gets exported separately from your app is smaller than the original SWC, so here again, you can't look at the SWC file size, you need to see how big it is when exported. Because the whole library is exported though, most of the time the library SWF file will be larger than the overhead the library would have imposed if merged into the code. For example, adding Mate to your app may increase the final file size by 20KB. Those 20KB can be removed if you externalize the library by creating an RSL. However, the RSL SWF will be 32KB, which is more than the 20KB you removed. But if you have at least 2 apps using Mate that point to the same RSL, then you will start saving bandwidth.

So, if you want to consider using a library for your Flex project, do not judge it by its SWC file size.

By the way, Mate's SWC file is now only 60KB. Thanks to a suggestion from Theo, we were able to remove the Flex framework dependencies that were included in the SWC and that were not really needed. Theo explains a bit more in the forums.