10 Replies Latest reply on Oct 22, 2010 2:49 PM by Marc Speck

    Min size of optimized Module 35kB?

    Marc Speck Level 1

      I wanted to minimize the size of our modules. So I created a new Flex Builder 4 project with Flex 4.0.0.14159 with an empty application and an empty module. The module is optimized for the application and the framework is linked as RSL. After creating a release, the size of the module file is 35672 Bytes. Is this really the minimal size of a module? This is a huge overhead when loading e.g. 10 modules.

       

      According to the link report, the module contains many RSL classes like mx.preloaders:SparkDownloadProgressBar (6977 Bytes) or mx.resources:ResourceManagerImpl (6341 Bytes). Does the module really need to include these classes? I have not verified it but IIRC Flex 3 modules where much smaller.

       

      Thanks for any clarification,

      Marc

        • 1. Re: Min size of optimized Module 35kB?
          aktell2007 Level 1

          Set the debug to false in the compiler and check again, but 35 kb does not sound that bad at all !

          regards aktell

          • 2. Re: Min size of optimized Module 35kB?
            Marc Speck Level 1

            Thanks, aktell. With "creating a release", I meant "Export Release Build..." in Flash Builder which does AFAIK not compile any debug stuff.

             

            What I do not understand is that classes from RSLs are included. I thought that Flash Player was able to load RSLs without any Flex classes.

            • 3. Re: Min size of optimized Module 35kB?
              Flex harUI Adobe Employee

              A link report will show you what is in that 35K

              • 4. Re: Min size of optimized Module 35kB?
                Marc Speck Level 1

                Thanks, Alex. As mentioned in the first post, I do not understand why flex classes are compiled into the module:

                 

                According to the link report, the module contains many RSL classes like mx.preloaders:SparkDownloadProgressBar (6977 Bytes) or mx.resources:ResourceManagerImpl (6341 Bytes). Does the module really need to include these classes? I have not verified it but IIRC Flex 3 modules where much smaller.

                 

                Second, the new style per module thing adds roughly 10kB even though I don't need it in any module. Is there a way to save this space?

                • 5. Re: Min size of optimized Module 35kB?
                  Flex harUI Adobe Employee

                  I think there was always a progressbar, but the Spark one is bigger.  It is

                  possible that some compatibilty check is bringing in ResourceManagerImpl.

                   

                  Feel free to file a bug about the latter.  I think you can replace the

                  progressbar.

                   

                  Per-module styles added overhead, but for a very important reason: modules

                  wouldn't unload in most cases without it.

                   

                  Also keep in mind that the numbers you see aren't completely accurate as the

                  actual SWF is compressed.

                   

                  If you're sure your code won't hit some class, you an -externs the class.

                   

                  If you are just bringing in classes and don't need resources and styles

                  infrastructure, then use ModuleBase and ActionScript.

                  1 person found this helpful
                  • 6. Re: Min size of optimized Module 35kB?
                    Marc Speck Level 1

                    Thanks for the helpful answer!

                     

                    So the module-specific styles are necessary for unloading modules, ok. What I still do not understand is why are all the other classes and interfaces from RSLs linked into the module. AFAIK the RSLs are loaded before the second frame, so why should a module link to any of these classes?

                     

                    What do you mean with "you can replace the progressbar"? Replacing it with an other implementation does not save that much space. Besides that SparkDownloadProgressBar is already in the link report, I also tried to externs the class. In both cases, SparkDownloadProgressBar was compiled into the module. Why is there a progessbar in modules anyway? They are potentially needed in applications in the first frame, but in modules?

                     

                    • 7. Re: Min size of optimized Module 35kB?
                      Flex harUI Adobe Employee

                      Modules can load their own RSLs.  I forgot that anything needed in the first

                      frame can't be externed.

                       

                      What is linking in SparkDownloadProgressBar?

                      • 8. Re: Min size of optimized Module 35kB?
                        Marc Speck Level 1

                        _MyModule_mx_core_FlexModuleFactory links SparkDownloadProgressBar (and DownloadProgressBar):

                         

                            override    public function info():Object
                            {
                                return {
                                    compiledLocales: [ "en_US" ],
                                    compiledResourceBundleNames: [ "components", "containers", "core", "effects", "layout", "skins", "styles" ],
                                    currentDomain: ApplicationDomain.currentDomain,
                                    height: "300",
                                    layout: "absolute",
                                    mainClassName: "MyModule",
                                    mixins: [ "_MyModule_FlexInit", "_MyModule_Styles" ],
                                    preloader: SparkDownloadProgressBar,
                                    width: "400"
                                }
                            }
                        

                         

                         

                         

                        _MyModule_mx_core_FlexModuleFactory also links to ResourceManagerImpl:

                         

                        _MyModule_mx_core_FlexModuleFactory dep:   FlexModuleFactory dep:   ResourceManager dep:   ResourceManagerImpl

                        • 9. Re: Min size of optimized Module 35kB?
                          Flex harUI Adobe Employee

                          Might be worth filing a bug to see if we can find ways around that.  You do

                          sort of want your resources available as soon as possible.