HomeDocs
Skip to main content

Subpackage Preloading

Supported from Core Library version 7.2.0 and above. Please use Developer Tools version 0.17.0 or above. Click here to download.

Developers can configure the framework to automatically preload subpackages when entering a specific page of the miniApp, thereby improving the startup speed of subsequent subpackage pages.

Configuration Method

The behavior of preloading subpackages is triggered when entering a specific page, controlled by adding the preloadRule configuration in app.json. It can also be triggered via the dlt.loadSubPackage API.

{
"pages": ["pages/index/index", "pages/tabTwo/tabTwo"],
"subPackages": [
{
"root": "packageA",
"pages": ["pages/cat/index", "pages/dog/index"]
},
{
"root": "packageB",
"name": "pack2",
"pages": ["pages/apple/index", "pages/banana/index"]
}
],
"tabBar": {
"list": [
{
"pagePath": "pages/index/index",
"text": "Home",
"iconPath": "images/tabbar/home.png",
"selectedIconPath": "images/tabbar/home-selected.png"
},
{
"pagePath": "pages/tabTwo/tabTwo",
"text": "TabTwo",
"iconPath": "images/tabbar/tabTwo.png",
"selectedIconPath": "images/tabbar/tabTwo-selected.png"
}
]
},
"preloadRule": {
"pages/index/index": {
"network": "all",
"packages": ["packageA", "packageB"]
},
"pages/tabTwo/tabTwo": {
"packages": ["pack2"]
}
}
}

In the preloadRule, the key is the page path, and the value is the preload configuration for entering that page. Each configuration contains the following items:

FieldTypeRequiredDefaultDescription
packagesString[]YesNoneThe root or name of the subpackages to preload when entering the page.
networkStringNowifiThe network condition for preloading. Valid values are described below.

Valid values for network

FieldDescription
allNo network restriction
wifiPreload only on WiFi
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.