Size Reduction Strategies
In almost any app, assets are always the primary size contributors. To reduce their impact on app size, you can follow some size reduction strategies such as:
- Removing unused assets.
- Optimizing (compressing) PNG / JPG images.
- Using modern animation file formats (lottie, rive) compared to GIFs.
- Not pre-bundling font files and using packages like
google_fonts
which fetches a specified font over the internet when the app runs for the first time. This font is subsequently cached in the device.
In case the size footprint of code-base is large, you should:
- Remove unused code.
- Split large classes that are difficult to optimize into smaller classes that will make it easier to identify and remove unnecessary code.
- Obfuscate your app to dramatically reduce code size.
- Choose efficient 3rd party packages that have a low size footprint. We will explore this point further in Scenario #2.