# Best practices

# 1. Avoid JS exceptions

appear JavaScript Exception may lead to the program interaction can not go on, we should pursue zero exception to ensure the high robustness and high availability of the program.

Score condition: No JS exception

# 2. Avoid network request exceptions

Failure of the request may cause the interaction of the program to fail, and all requests should be guaranteed to succeed.

Scoring condition: all authorized network requests are returned normally, unauthorized network requests need to be given 401 or 403 These two state codes

# 3. Do not use deprecated interfaces

Using a soon-to-be-deprecated or deprecated interface may cause the Mini Program to behave incorrectly. In general, the interface will not be removed immediately, but to be on the safe side, it is recommended not to use it to avoid sudden abnormal operation of subsequent Mini Programs.

Scoring condition: Do not use any interface in the document that suggests abandonment

# 4. Use HTTPS

useHTTPSThis will make your little program safer.HTTPIs transmitted in plaintext, there is a risk that the content may be tampered with

Scoring condition: All network requests useHTTPS

# 5. Avoid setData data redundancy

The setData operation causes the framework to handle some rendering interface-related work. An unbound variable means nothing to do with rendering the interface. Passing setData in can cause unnecessary performance consumption.

Scoring conditions:setDataAll incoming data has relevant dependencies in the template rendering

# 6. Minimum base version

When the components used/API Is greater than the configured online minimum base library version, may render the corresponding functionality unavailable. The developer can pass[Adjust the minimum base library version](../compatibility.md#Setting the minimum base library version)Or in theCompatible code.Ways to solve the problem.

Because the user can solve this problem in a code-compatible way, the metric serves only as a reminder of the score and does not count toward the overall score.

Judgment Criteria: No components used/API The supported version is greater than the configured minimum online base version

# 7. Remove inaccessible pages

The package size of the Mini Program will affect the loading time, and you should try to control the package size to avoid packaging files that will not be used.

Because this indicator depends on the developer's action path, it is only used as a reminder of the score and is not counted in the total score.

Judgment criteria: There is no page that can not be accessed is packaged into a Mini Program

# 8. WXSS Usage

We should introduce them on demand wxss Resources, if there are a lot of unused styles in the Mini Program, it will increase the size of the Mini Program package, which will affect the loading speed to some extent.

Because this indicator depends on the developer's action path, it is only used as a reminder of the score and is not counted in the total score.

Judgment Criteria: Each wxss The unused portion of the resource does not exceed 2KB

# 9. Timely recovery timer

Timer is global, is not bound with the page, when the Mini Program from a page routing to another page, the previous page timer should pay attention to manual recovery.

Because this indicator depends on the developer's action path, it is only used as a reminder of the score and is not counted in the total score.

Judgment standard: all timer callbacks are executed on the same page as the page that set the timer