lightning-load-project
Page preloading framework for mini program performance optimization
introduce
I saw an article before, "Tips for Improving Application Speed of WeChat Mini Programs", which talks about how to implement the mini program to request the protocol before triggering the page jump, and use the short 200~300ms time to jump to the page to obtain The data is rendered to a new page, enabling data to be preloaded in the mini program page. This technology can shorten the user's waiting time and greatly improve the user experience. But that article only described the technical principles and did not actually teach you how to write it, so I wrote this page preloading framework.
Framework advantages and disadvantages
advantage:
- Preloading the data of the next page improves the loading speed of the page. The lightweight protocol (data can be received in about 200~300ms) can easily load the data instantly after the mini program page is opened, and almost no empty pages appear.
- Keeping code for the same business in one class will not destroy the project structure.
- The amount of code is very small, and the impact on the original business is very small.
- Preloading is injected when the mini program is initialized, and pages that do not implement preloading will be automatically skipped.
- Want to delete preloading after implementing preloading? Just delete a string in the implemented class.
shortcoming:
- The code is highly intrusive and you need to replace
setData
with $setData
according to the situation. - Developers need to be very clear about what the context of each situation is.
- The protocol is very time-consuming, reaching more than 400ms, so it is not obvious to use this optimization method.
Projects using this technology
LINK
Integration method documentation
Technical principle document
LICENSE
Thanks for the ideas provided by this article: Tips for improving application speed of WeChat Mini Programs