HomeDocs
Skip to main content

Code Package Size Optimization

The most direct way to optimize startup performance is to reduce the size of the code package. The size of the code package directly affects download time, which in turn affects the user experience when starting the mini-program.

Developers can take the following measures to optimize the size of the code package:

1. Control Resources in the Code Package

When downloading a mini-program, the code package is compressed. Resource files such as images, audio, video, and fonts occupy a large portion of the code package size and are often difficult to further compress. They have a much greater impact on download time compared to code files.

It is recommended that developers include only small-sized icons and images in the code package. Avoid including or using too many or too large images and other resource files, such as base64 inline images, in the code package or CSS. Instead, deploy these files to a CDN and use URL references.

2. Timely Cleanup of Unused Code and Resources

When packaging a mini-program, all files in the project directory are included in the code package. Files and resources that are accidentally included, deprecated code or dependencies in version iterations, test code not needed in production environments, and unused components will also be included in the code package if not cleaned up, thus affecting the size of the code package.

It is recommended to periodically clean up unused code to optimize the size and content of the code package.

Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.