# Subcontract Predownload
Start from base library version 2.3.0. Please remaining backward compatible. Developer Tools Please use 1.02.1808300 And above version, mayClick here to download。
Developers can configure the framework to automatically pre-download the sub-packages that may be required when entering a page of the Mini Program, improving the start-up speed when entering the subsequent subcontract page. forIndependent subcontract , can also pre-download the main package.
Subcontracting predownloads are currently only supported by configuration and are not supported by calling the API.
vConsole Ryu
preloadSubpackages
The initial log information can be used to verify the pre-download.
# Configuration method
The pre-download subcontract behavior is triggered when a page is entered, by entering the app.json
increase preloadRule
Configuration to control.
{
"pages": ["pages/index"],
"subpackages": [
{
"root": "important",
"pages": ["index"],
},
{
"root": "sub1",
"pages": ["index"],
},
{
"name": "hello",
"root": "path/to",
"pages": ["index"]
},
{
"root": "sub3,"
"pages": ["index"]
},
{
"root": "indep",
"pages": ["index"],
"independent": true
}
],
"preloadRule": {
"pages/index": {
"network": "all",
"packages": ["important"]
},
"sub1/index": {
"packages": ["hello", "sub3"]
},
"sub3/index": {
"packages": ["path/to"]
},
"indep/index": {
"packages": ["__APP__"]
}
}
}
preloadRule
In,key
Is the page path,value
Is the pre-download configuration that goes to this page. Each configuration has the following:
field | type | Required | Default value | Introductions |
---|---|---|---|---|
packages | StringArray | yes | nothing | Pre-download the subcontract after entering the page root or Name 。__APP__ Represents the primary package. |
network | String | no | Wifi | Predownload under the specified network with an optional value of:all : Unlimited network Wifi : Pre-Download on Wifi Only |
# limit
Common pre-download size limits for pages in the same subcontract 2M, the limit is checked when packaged in the tool.
Such as, page A and B All in the same subcontract. A Medium Predownload Total Size 0.5M The total size of the subcontract, B can only be pre-downloaded at most 1.5M The sub-packageing.