When Size Matters

Modules or RSLs, whatever way you partition your Flex system, if you are delivering it over the public web you want to keep the size as small as possible. What are the best options?

Flex compilers support -link-report option. It let’s you produce a file of the linker dependencies found during the build of your SWF. Then there is a matching -load-externs option that let you specify the classes you do not want to link, but rather prefer to extern. Conveniently, -load-externs anticipates the input to be in exactly the same XML format as is produced by -link-report.

Speaking of modules and applications – just as an example case – this pair of options enables you to extern for the module everything, that will be loaded by the application. You build your application producing -link-report, then apply it for the module (see Flex docs for exact details). However, if you plan to ever reuse the same module for the different hosting application, this technique is not applicable. You’d need to rebuild the module.

There is an opposite way of using -link-report option. If you use compiler’s option –include you can have application merge-in all classes required by your libraries .

In this scenario, you run -link-report on the module and instead of optimizing the module, you optimize the application. No need to rebuild your modules to satisfy every individual application – they stay 100% reusable. Instead you tune your applications.

And, speaking of size, do not forget the -debug option. By turning it to false you may strip up to 30% of size taken by debugging information. By the same token, you may want to recompile framework.swf from Adobe Flex Framework source files to take it’s size down in the first place, prior to resorting to –include.

Keep it small.


One thought on “When Size Matters

  1. Is there a way I can use link-report xml to optimize and reuse with -load-externs to recomplile an application instead of module.

    Tested scenario:

    It creates a sizeReport.xml, then I used the same xml to rebuild the application with the below code.

    It compiles, but it is showing some runtime error. Can you please throw some light on this.


Comments are closed.