How does the WeChat applet work in the WeChat APP?

How does the applet run in the WeChat App?

WeChat App contains javascript running engine.

The WeChat App contains the WXML/WXSS processing engine, which will eventually translate the interface into the system's native controls and display them. The purpose of this is to provide a user experience comparable to native app performance.

quote
This article comes from the "H5 Program Club" public account
"H5 Program Club" is a WeChat public account that focuses on WeChat applet learning and communication, and the release of relevant outsourcing/recruitment needs information




Let's simulate the process of loading and running the applet: the user

clicks to open a applet,

the WeChat App downloads the applet from the WeChat server,

analyzes the app.json, and obtains the configuration information of the application (navigation bar, window style, list of included pages, etc.)

And run app.js

to load and display the first page configured in app.json

This is just a simplified version of the process seen from the developer's eyes, the actual process should be much more complicated than this, involving browser threads ( It is the interaction between the thread that runs our logic layer code, app.js, etc.) and the AppService thread. From a picture on the official website, we can see the clue:



how does the WeChat App interact with the logic layer javascript of the applet? It can be summed up simply as follows:

JavaScript is a scripting language that can be interpreted and executed at runtime. The WeChat App contains a JavaScript engine, which is responsible for executing the JavaScript code of the logic layer. So how is the API related to the applet called by JavaScript implemented? The answer is that it will eventually be translated into a native interface implemented in the WeChat App. For example, the developer calls wx.getLocation(OBJECT) to obtain the current geographic location. When the JavaScript engine in the WeChat App executes this code, it will call the native interface implemented in the WeChat App to obtain the geographic location coordinates.

It can be seen from the above process that the operating environment of the WeChat applet should be more similar to ReactNative, rather than pure Html5. The biggest difference between the two is that the ReactNative interface is rendered by native controls, while the Html5 interface is rendered by the browser kernel. There is a big difference in performance between the two.

The biggest advantage of WeChat Mini Programs is that no device adaptation is required. As long as WeChat can run, the Mini Program can run.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326429178&siteId=291194637