WeChat Mini Program - Failed to upload the code, prompting that the subpackage size exceeds the limit

Developers can use the performance scanning tool in the developer tool to discover the optimizeable items in the code in advance:

1. The code package does not contain plugins whose size exceeds 1.5 M

[Suggestion] The size limit of a single applet code package is 2M. Therefore, we recommend that developers, if the size of a single package is larger than 1.5M during development, they can adopt the method of subpackaging, split part of the code into subpackages, reduce the volume of a single package, and improve the loading speed of small programs . For details, please refer to the document "Using subpackages" .

2. The size of the referenced plugin exceeds 200K

[Notification] The size of the applet plug-in will be counted into the 2M size limit of the applet code package. Therefore, when we find that the volume of the plug-in cited by the developer is greater than 200K, we will give a reminder to the developer to avoid the problem that the volume of the code package exceeds the limit during the upload stage, but we don’t know why it exceeds the limit.

3. The image and audio resource size exceeds 200K

[Suggestion] Some necessary static resources (such as tabbar icons, etc.) can be stored in the applet code package; however, the large size of other non-essential static resources will affect the loading speed of the applet code package. Therefore, we recommend that when the size of static resources such as pictures and audio exceeds 200K, upload them to CDN, and importing them with URL will be a better choice.

4. The main package contains JS that is only depended on by other subpackages

[Suggestion] When there are some JS files in the main package that will only be used by sub-packages (and not used by the main package), we suggest splitting these JS files from the main package and putting them into corresponding sub-packages to optimize The loading speed of the main package.

5. The main package has components that are only dependent on other subpackages

[Suggestion] When there are some components in the main package that will only be used by sub-packages (and not used by the main package), we recommend that these components be separated from the main package, and these components can be loaded using the asynchronous feature of sub- packages . This optimizes the loading speed of the main package.

6. There are unused plugins

[Required] If there are unused plugins, remove them from app.json. Otherwise, it will take up the size of the code package and delay the loading time of the code package.

7. There are unused components

[Required] If the component declared in `usingComponents` of the corresponding page JSON is not used, please remove it from `usingComponents`.

8. JS compression is not enabled

[Required] Turn on the setting of "Automatically compress script files when uploading code" in the tool "Details" - "Local Settings"

9. WXML compression is not enabled

[Required] Enable the setting of "Automatically compress wxml files when uploading code" in the tool "Details" - "Local Settings"

10. WXSS compression is not enabled

[Required] Enable the setting of "Automatically compress style files when uploading code" in the tool "Details" - "Local Settings"

11. There is no dependency file

[Required] In the "Code Quality" panel, after clicking "Suggest Removal", you can open the "No Dependency Files" page of the code dependency analysis panel, where you can see the files that are not used in the code package. Please remove these files from the code package to reduce the size and optimize the loading speed.

In the process of local development, files without dependencies will be automatically filtered. If there is a false filter, you can add ignoreDevUnusedFiles to false in the setting field of project.config.json, or manually ignore it in the include field of packOptions  The file is introduced, and welcome to post feedback on false positives and submit code snippets to help us improve this function

Note: If the page is configured in app.json, it will be recognized as a non-dependent file

12. Component lazy injection is not enabled (on-demand injection)

[Mandatory] Add `"lazyCodeLoading": "requiredComponents"` in app.json to enable the on-demand injection feature of applet components .

Guess you like

Origin blog.csdn.net/weixin_64051447/article/details/131323655