HomeDocs
Skip to main content

Best Practices

1. Avoid JavaScript Exceptions

JavaScript exceptions can interrupt program execution and lead to a poor user experience. Strive for zero exceptions to ensure high robustness and availability of the program.

Official Advice: No JavaScript exceptions occur

2. Avoid Network Request Failures

Failed network requests can disrupt program execution. Ensure that all requests are successful.

Official Advice: All authorized network requests return normally, and unauthorized network requests should return either 401 or 403 status codes

3. Avoid Deprecated Interfaces

Using deprecated or soon-to-be-deprecated interfaces may cause the mini-program to malfunction. Although deprecated interfaces are not immediately removed, it's advisable to avoid using them to prevent unexpected issues.

Official Advice: Do not use any interfaces listed as deprecated in the documentation

4. Use HTTPS

Using HTTPS ensures the security of your mini-program. HTTP, being plaintext, poses the risk of content tampering.

Official Advice: All network requests should use HTTPS

5. Avoid Redundant setData Calls

Calling setData triggers framework operations related to rendering the interface. Passing an unbound variable to setData incurs unnecessary performance overhead.

Official Advice: All data passed to setData has relevant dependencies in template rendering

6. Minimum Base Library Version

When using components/APIs whose supported versions are higher than the configured minimum base library version, certain functionalities may become unavailable. Developers can resolve this issue by adjusting the minimum base library version or ensuring compatibility in the code.

Criteria: There are no components/APIs being used with supported versions higher than the configured minimum base library version

7. Remove Inaccessible Pages

The size of a mini-program affects loading time. Unused files should be excluded from the package to control the package size.

Criteria: There are no inaccessible pages included in the mini-program package

8. CSS Usage Rate

CSS resources should be imported as needed. Including a large number of unused styles in the mini-program increases the package size and affects loading speed to some extent.

Criteria: The unused portion of each CSS resource does not exceed 2KB

9. Timely Timer Recycling

Timers are global and not bound to specific pages. After navigating from one page to another in the mini-program, timers from the previous page should be manually recycled.

Criteria: All timers are executed on the page where they were set

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