


What else can be done besides subcontracting if the size of the mini program exceeds the limit? How to avoid and solve size limitations?
Jan 04, 2022 am 10:20 AMWhat else can be done besides subcontracting if the size of the mini program exceeds the limit? Is there any way to avoid exceeding the size limit? The following article will introduce to you how to avoid and solve size restrictions. I hope it will be helpful to you!
A few days ago, a friend who just joined the industry asked me on WeChat why the code prompt when submitting a small program was too large and could not be uploaded? How to deal with it?
Of course subcontracting can solve almost all submission size limitations of WeChat mini programs, but I still asked him to send me the prompt content. I saw that it exceeded four to five hundred kb. If subcontracting is not overkill, just let him compress the static resources and it will be done. But later I thought about subcontracting, besides solving the problem of size, what other benefits does subcontracting have? Is there any way to avoid exceeding the size limit?
Text:
The current size limit of WeChat applet and why the size should be limited:
1??Read it first Let’s take a look at the current size restrictions on WeChat mini programs:
? 1. There is no limit on the number of subcontracts;
? 2. The size of all subcontracts cannot exceed 20m;
? 3. The size of a single package cannot exceed 2m. ;
2??So why do WeChat mini programs have size restrictions?
The original intention of the design of the applet is to go after use, lightweight application. It is not recommended to design it as an app, so the size is limited in consideration of startup speed and other aspects.
What are the ways to avoid and solve the size limit:
Knowing the above related restrictions, then we can try to avoid the size of our small program exceeding the limit during the development process. 2m (of course it’s the kind of shopping mall that’s very big, so I didn’t mention it)
1. Use third-party libraries to load as much as possible
For example, if you use echarts in a project, we may usually use several icons, so there is no need to download all echarts during installation. You can directly customize it online on the echarts official website. It can save more than one and a half points in size (echarts China map has problems and is not recommended). Similar to some UI libraries we use, if it can be imported on demand, it can be imported on demand. If it cannot be imported on demand, we will change it.
Here we recommend some commonly used UI library collections for WeChat mini programs
1. Official WeUI component library
https://developers.weixin.qq. com/miniprogram/dev/extended/weui/
2、ColorUI
https://github.com/weilanwl/ ColorUI
3、Vant Weapp UI
https://youzan.github.io/vant-weapp/#/intro
4、iView UI
https://weapp.iviewui.com/docs/guide/start
5、TaroUI
https://taro-ui.jd.com/#/docs/introduction
How to adjust the image size
2. Compress images and other static files
A lot of pictures will definitely be used in the project. Usually, the design will give us two times the picture and three times the picture for a picture, allowing us to display different times the picture according to different resolutions. In fact, as a crude method, we can use triple the image regardless of the resolution (not recommended), and then compress the image losslessly, which can generally reduce the size of the image by 70%.
Recommend an image compression address here (https://tinypng.com/)
3. Static resource cloud service
Reduce The static resources occupy the space in the packaged files. You can also put the static files used in the project on OSS. You can use CDN to accelerate and reduce the code size. If you want to make your own cloud server to store static resources, it is recommended to use Qiniu Cloud.
Register a Qiniu Cloud account->Find the object storage in all products->Upload pictures->Copy link
??Note: Sometimes you need to configure anti-leeching if you cannot access it. How to configure it? We use Baidu on our own.
4. Use subcontracting
Coming to our orthodox method of solving size restrictions, let’s first look at the question raised at the beginning of the article: In addition to subcontracting What are the benefits of being able to solve the problem of size? To answer this question, first understand how subpackaging works: When the mini program is started, the main package will be downloaded by default and the page in the main package will be launched. When the user enters a page in the subpackage , the client will download the corresponding subpackage and display it after the download is completed.
Then the above question is easy to answer: subcontracting the mini program can optimize the download time for the first startup of the mini program, and can better decouple collaboration when multiple teams develop together.
So what should we do if we want to subcontract? : The following lists the commonly used subcontracting methods of native, uniapp, and taro. The three development methods for subcontracting except that the names of configuration files are different, the codes are the same. The key is the project directory andsubpackagesField.
Native:
// 在app.json的subpackages字段聲明項(xiàng)目分包結(jié)構(gòu) { "pages":[ 主包 "pages/index", "pages/logs" ], "subpackages": [ 分包 { "root": "packageA", "pages": [ "pages/cat", 相對于root分包的路徑 "pages/dog" ] }, { "root": "packageB", "name": "pack2", "pages": [ "pages/apple", "pages/banana" ] }, { root:分包根目錄 name:分包別名,分包預(yù)下載時(shí)可以使用 pages:分包頁面路徑數(shù)組,相對與分包根目錄 independent:true|false分包是否是獨(dú)立分包 } ] }
uniapp:
// 在pages.json的subpackages字段聲明項(xiàng)目分包結(jié)構(gòu) 代碼同原生,關(guān)鍵就是subpackages字段
taro:
// 在src目錄下app.jsx中進(jìn)行配置 代碼同原生,關(guān)鍵就是subpackages字段
Conclusion:
WeChat applet subcontracting is actually a very simple operation, but there is also asynchronous subcontracting ization, pre-downloading, independent subcontracting and other knowledge still need to be studied by the bosses when they use it again.
Finally, I participated in this annual popularity ranking some time ago. In fact, I also know that this list does not represent anything, but the final result of ranking 54 still made me feel vain. I think the meaning of this logo to me is to urge me to output higher-quality articles in the new year, so that I can really deserve this title. Let’s work hard together, everyone.
Finally, I wish you all great progress in your studies and success in your career!
[Related learning recommendations: 小program development tutorial]
The above is the detailed content of What else can be done besides subcontracting if the size of the mini program exceeds the limit? How to avoid and solve size limitations?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

With the popularity of mobile Internet technology and smartphones, WeChat has become an indispensable application in people's lives. WeChat mini programs allow people to directly use mini programs to solve some simple needs without downloading and installing applications. This article will introduce how to use Python to develop WeChat applet. 1. Preparation Before using Python to develop WeChat applet, you need to install the relevant Python library. It is recommended to use the two libraries wxpy and itchat here. wxpy is a WeChat machine

Implementing card flipping effects in WeChat mini programs In WeChat mini programs, implementing card flipping effects is a common animation effect that can improve user experience and the attractiveness of interface interactions. The following will introduce in detail how to implement the special effect of card flipping in the WeChat applet and provide relevant code examples. First, you need to define two card elements in the page layout file of the mini program, one for displaying the front content and one for displaying the back content. The specific sample code is as follows: <!--index.wxml-->&l

According to news from this site on October 31, on May 27 this year, Ant Group announced the launch of the "Chinese Character Picking Project", and recently ushered in new progress: Alipay launched the "Chinese Character Picking-Uncommon Characters" mini program to collect collections from the society Rare characters supplement the rare character library and provide different input experiences for rare characters to help improve the rare character input method in Alipay. Currently, users can enter the "Uncommon Characters" applet by searching for keywords such as "Chinese character pick-up" and "rare characters". In the mini program, users can submit pictures of rare characters that have not been recognized and entered by the system. After confirmation, Alipay engineers will make additional entries into the font library. This website noticed that users can also experience the latest word-splitting input method in the mini program. This input method is designed for rare words with unclear pronunciation. User dismantling

Mini programs can use react. How to use it: 1. Implement a renderer based on "react-reconciler" and generate a DSL; 2. Create a mini program component to parse and render DSL; 3. Install npm and execute the developer Build npm in the tool; 4. Introduce the package into your own page, and then use the API to complete the development.

How uniapp can achieve rapid conversion between mini programs and H5 requires specific code examples. In recent years, with the development of the mobile Internet and the popularity of smartphones, mini programs and H5 have become indispensable application forms. As a cross-platform development framework, uniapp can quickly realize the conversion between small programs and H5 based on a set of codes, greatly improving development efficiency. This article will introduce how uniapp can achieve rapid conversion between mini programs and H5, and give specific code examples. 1. Introduction to uniapp unia

This article brings you some related issues about WeChat mini programs. It mainly introduces how to use official account template messages in mini programs. Let’s take a look at them together. I hope it will be helpful to everyone.

Implementation idea: Establishing the server side of thread, so as to process the various functions of the chat room. The establishment of the x02 client is much simpler than the server. The function of the client is only to send and receive messages, and to enter specific characters according to specific rules. To achieve the use of different functions, therefore, on the client side, you only need to use two threads, one is dedicated to receiving messages, and the other is dedicated to sending messages. As for why not use one, that is because, only

Geolocation positioning and map display of PHP and mini programs Geolocation positioning and map display have become one of the necessary functions in modern technology. With the popularity of mobile devices, people's demand for positioning and map display is also increasing. During the development process, PHP and applets are two common technology choices. This article will introduce you to the implementation method of geographical location positioning and map display in PHP and mini programs, and attach corresponding code examples. 1. Geolocation in PHP In PHP, we can use third-party geolocation
