On-Demand Injection
Skyline relies on the On-Demand Injection feature. Once the On-Demand Injection feature is enabled, the behavior of Mini Program may change, potentially causing compatibility issues (see the On-Demand Injection feature documentation for details). Therefore, it is recommended to enable On-Demand Injection and thoroughly test your Mini Program before starting Skyline adaptation, to proactively mitigate any impact caused by this feature.
Progressive Migration
For existing projects, a progressive migration approach is recommended. Specifically, enable the feature page by page. It is advised to prioritize migrating key pages on the critical path of the Mini Program to ensure a better experience for the majority of users. For newly added pages, it is recommended to enable Skyline by default. For entirely new projects, it is recommended to enable it globally, which not only provides a better user experience but also reduces the memory footprint of the Mini Program.
Using Local Scrolling
In the WebView, the entire page is scrollable by default. As a result, most developers directly utilize global scrolling, which leads to:
- Elements that do not require scrolling are fixed in place using
position: fixed, such as custom navigation bars. This simulates local scrolling with global scrolling, causing the scrollbar to overflow its intended position. - Custom features for scrolling can only be provided through configuration or APIs, such as
Page.onPageScroll, which also prevents certain features from being implemented.
Therefore, Skyline no longer provides global scrolling. Use the scroll-view component to implement scrolling in the required areas. This approach also allows us to provide more extensions specifically for the scroll-view component in the future.
Generally, most UI layouts consist of a navigation bar plus a scrollable area. Here is a standard approach (compatible with WebView):
<navigation-bar></navigation-bar>
<!-- Use Flexbox layout, setting scroll-view to flex:1 to occupy the remaining space of the page -->
<scroll-view type="list" scroll-y style="display: flex; flex-direction: column; flex: 1; width: 100%; overflow: auto;">
<view wx:for="{{items}}" list-item></view>
</scroll-view>
Global Style Reset
The WXSS supported by Skyline is a subset of WebView. More necessary or commonly used features may be supported in the future, but it will always remain a subset of WebView.
Therefore, to align the WebView compatibility behavior with Skyline as closely as possible and reduce redundant configuration code, it is recommended to globally enable the following configuration options:
rendererOptions: {
"skyline": {
"defaultDisplayBlock": true,
"defaultContentBox": true,
"tagNameStyleIsolation": "legacy",
"enableScrollViewAutoSize": true,
}
}
Also, consider applying the following WXSS Reset globally or at the page level:
page,
view,
text,
image,
button,
video,
map,
scroll-view,
swiper,
input,
textarea,
navigator {
position: relative;
background-origin: border-box;
isolation: isolate;
}
page {
height: 100%;
}
Optimizing Long List Performance
The scroll-view component in Skyline comes with built-in on-demand rendering optimizations, which significantly improve the rendering performance of long lists. On-demand rendering is applied at the granularity of direct child nodes of scroll-view. A child node is rendered when it approaches the viewport of the scroll-view and is recycled when it moves away.
<!-- The direct child nodes of the scroll-view below are 5 views, and each view is rendered on demand -->
<scroll-view type="list" scroll-y>
<view> a </view>
<view> b </view>
<view> c </view>
<view> d </view>
<view> e </view>
</scroll-view>
<!-- The scroll-view below has only 1 direct child view, so on-demand rendering does not take effect -->
<scroll-view type="list" scroll-y>
<view>
<view> a </view>
<view> b </view>
<view> c </view>
<view> d </view>
<view> e </view>
</view>
</scroll-view>
In addition, items in a long list usually share similar styles. Skyline also supports style sharing for similar nodes, allowing styles to be calculated once and shared with other similar nodes, which greatly improves style calculation performance. Typically, we use the WXML template syntax wx:for to expand lists. Therefore, declaring list-item on list items enables style sharing (future versions will automatically enable it by detecting wx:for).
<scroll-view type="list" scroll-y>
<view wx:for="" list-item> {{index}} </view>
</scroll-view>
Preloading
Mini Program includes a significant optimization: preloading the environment, which covers the WebView environment, the AppService thread, and early injection of the base library. However, since most Mini Program currently rely on WebView rendering, WeChat clients do not automatically preload the Skyline environment to conserve resources (this strategy will be continuously optimized based on actual scenarios). Therefore, we provide the wx.preloadSkylineView API to preload the Skyline environment. Developers can manually invoke this API along paths where navigation to a Skyline page is anticipated. It is recommended to call this with a delay within the onShow lifecycle, ensuring that the Skyline page is re-preloaded when returned to.
Using Enhanced Features
To bring the experience of Mini Program closer to that of native apps, Skyline introduces several new features, including the worklet animation mechanism, gesture system, custom routing, and shared element animations. These features enable Skyline to achieve interactive effects that are either impossible or lack smoothness in WebView environments.
Since WebView does not support these features, we recommend adopting a graceful degradation strategy for compatibility. For instance, with custom routing, page navigation via the wx.navigateTo API utilizes custom routing animations in Skyline for a superior experience, while in WebView, it falls back to the standard right-to-left page transition animation. Similarly, shared element animations follow the same principle, requiring no additional compatibility code.