Today’s work has been finished, in soon to enter the May Day holiday off work anxious moment, to a simple summary of micro channel small program development specifications.

1. Applets should avoid any JavaScript exceptions

The occurrence of JavaScript exceptions may lead to the failure of the interaction of small programs. We should pursue zero exceptions to ensure the high robustness and high availability of small programs. We believe that this will not happen in general.

2. Properly control the size of the picture

Too many pictures will increase the download time and memory consumption, should be based on the display area size reasonable control picture size. Under normal circumstances, the picture is larger, we should choose to directly put on the server, directly get the address, but the official said so read the picture: there are network picture resources do not open HTTP cache control, what is this meaning, I do not fully understand.

3. All requests of the applet should be responded normally

Failure of the request may result in failure of the applet interaction, and all requests should be guaranteed to succeed. However, successful requests are only the first step, and there can be problems such as requests that take too long or too many requests in a short period of time.

4. Avoid large setData and frequent calls of setData.

The small program to perform logic thread and rendering thread, setData calls will spread from logic layer to render the data layer, too much data can increase communication time. SetData interface calls involving thread between logic and rendering layer, communication too often may cause processing queue jam, slow interface rendering cause caton, Unnecessary frequent calls should be avoided.

5. Avoid passing variables into setData that are not bound to WXML

The setData operation causes the framework to handle some of the work associated with rendering the interface. An unbound variable means that it has nothing to do with rendering the interface, and passing in setData incurs unnecessary performance costs. This is a mistake I think many developers make when they are first introduced to applets. In the beginning, we forgot about the use of global variables because of the syntax of setData, so we often use data defined in Page for intermediate transitions.

6. WXSS has high coverage and introduces few or no unused styles

We should introduce WXSS resources as needed, because a large number of unused styles in the applets will increase the size of the applets and thus affect the loading speed to some extent. This is also a common kind of non-standard, write a lot of CSS style, a lot of unnecessary left in the code, more and more, so in the process of writing code, try to know every line of code (especially their own) like the back of their hand.

7. Avoid long screen time

The first screen time refers to the time when the user starts to view the content on the first screen. If the first screen time is too long, the user will see a blank screen for a long time, waiting for meaningful content to be displayed. When this happens, you should carefully examine which operations are involved in the process. In general, it may take too long to request data or render too much data at one time.

These are the things THAT I find common and easy to fix. There are other specifications that exist. Open the wechat developer tools, click on Audits, and run a test of the code you write that will allow you to handle your code nicely. That’s really cool!