25 kB 23 kB.
- faster download: faster application installation or startup.
- faster parsing for the browser: faster startup.
And smaller also means you can have far more complex applications for a given size budget.
Using “Nickel Iron” as illustration
When obfuscation is active, the CodeGen will replace most identifiers with shorter versions, usually 1 to 3 characters in length.
Optimize for Size
Optimize for size triggers two mechanisms in the CodeGen:
- alternative code generation templates are used, which spit out less readable but smaller code. At this point, there is no choice between size and performance, only between more and less human-readable.
The minifier is applied to “asm” sections too, and performs “safe” minifications only.
Just like in Delphi, smart linking will eliminate functions methods and classes you have in the Pascal source, but never use in your program.
However, just like in Delphi, Smart Linking works best if your code is well decoupled, if you use dependency-injection and other light-coupling design approaches. So avoid coding spaghetti plates 😉
At the time this article was written, the DWScript Smart-Linker limitations are :
virtual or interfaced methods of a class you use aren’t eliminated (same limitation as in Delphi)update 02/08: now supported, was simpler than anticipated.
- there is no de-virtualization just yet (same limitation as in Delphi).
- cross-referencing functions aren’t eliminated (procA calls procB, and procB calls procA), though as this may be more of a sign of a code smell, it might just be getting a compiler “hint” rather than smart-linker support.