Small program code has a 2M limit, causing us to be timid in our development. Now we can make the whole small program up to 8M by subcontracting.
Use of the subcontract
First, we create a file called SubPackage in the root directory and create the Child page underground
Then declare the project subpackage structure in the app.json subpackages field:
View the current size of the main subpackage in details
Independent of the subcontract
Independent subcontracting is a special type of subcontracting in small programs that can operate independently of the main package and other subcontracting. There is no need to download the main package when entering the applet from the standalone subcontracting page. The main package is downloaded only when the user enters the normal package or main package page.
We simply define the independent field in the subpackages field of app.json in the corresponding subpackages configuration item and declare the subpackages to be independent subpackages.
Subcontract preloading
When entering a page of the small program, the framework will automatically pre-download the subcontracting that may be needed to improve the startup speed when entering the subsequent subcontracting page. For standalone subcontracting, the main package can also be pre-downloaded.
The preload subcontract behavior is triggered when entering a page and is controlled by adding a preloadRule configuration to app.json. For example, after entering the show_load page of the main package, preload the subpackages