views:

773

answers:

6

Hello world application that uses Flex, compiled with optimize=true has size 178K. How to reduce application size?

We do not like to use RSL, we don't like to avoid Flex.

Largest part of resulting SWF is unused bytecode. Are there any tools to optimize bytecode — drop unused methods, classes, give methods shorter names and so on?

I know some such tools for Java bytecode. Any there any for SWF?

+1  A: 

You could try some Flash Optimizer on it, but I doubt things will get much better. Isn't it possible for you to change the source code, do the optimizations you mentioned and recompile the application?

Or are you talking about Flex overhead? If so, you shouldn't care, as for bigger projects this will stay almost the same, and if it grows, it's because of some classes or methods you need (Multimedia etc.).

schnaader
Size of source code of my hello world application is only 1k (including MXML formatting overheads).I'll try Flash Optimizer (unfortunately it works only on Windows).
stepancheg
Which OS are you using? There are optimizers for Mac (http://mac.eltima.com/swf-compressor.html) and Linux (http://wareseeker.com/Web-Development/dcom-swf-optimizer-for-linux-1.0.zip/389574) too.
schnaader
SWF Compressor (for Mac) does not optimize code. After optimization, size reduced for 0.07%.
stepancheg
So I guess you shouldn't bother. 178K for a Hello world application is much, but as I said, the overhead shouldn't get much worse for bigger projects.
schnaader
Project is big, but the site must be kept lite.
stepancheg
It's worth noting that the front pages of many major internet news portals with HTML/JS/CSS are now generally 150-800KB total. That's a pretty comparible size range for all but the largest Flex applications.
joshtynjala
+3  A: 

The size is the cost of the Flex API. You don't get to pick and choose which parts are compiled in, so the best case is going to still carry a lot of baggage.

If size is a big worry, you can get away with using only the flash side of ActionScript, but you lose out on a lot of the nice prebuilt Flex components.

enigmatic
+1  A: 

Why not RSL? Keeping the flex framework separate as an RSL seems the only option worth considering in your case. The RSL gets cached between requests.

The optimizers won't dramatically reduce the size if it's already as low as 178k. Also, looking at that size, I presume you are not embedding any images or other resources. If you are, taking them out and loading them dynamically will help too, but at the cost of making more HTTP requests.

Chetan Sastry
No RSL, because full Flex RSL size is about 1Mb, I'm afraid user won't visit my site again after waiting of loading 1Mb flash app. Site must be kept lite.
stepancheg
A: 

Well - is this a case of choosing the right tool? If you need to create an application - I wouldn't think the overhead to be too detrimental. If you are creating a website, I can see where you might want a smaller filesize - you might need to use pure actionscript without the overhead of the flex framework.

You did say that you didn't want to avoid flex - do you mean flex builder or the flex framework? You can still use flex builder to create actionscript only projects and it's a dream compared to the actions panel in CS4...

onekidney
A: 

try this link about flex file size optimization.
http://askmeflash.com/article_m.php?p=article&id=9

These are the major improvements that can be done.All applications created in Flex run on Flex framework so the basic framework has to be there. For example , if you are using a container then Classes like Event manager, Stylesheet manager, Stage, Application, are a must which make initial size of flex application and cant be avoided. The other alternative is using flash only.

Sydney
Page contains trivial advices, I already knew. This advices do no help saving much. I asked about real optimization.
stepancheg
A: 

You want to use Flex AND you want your project to be small. But Flex is large.

It sounds like you must make a decision.

Mims H. Wright
Flex is large, but the small part of Flex I need is small.
stepancheg