search
HomeWeChat AppletMini Program DevelopmentBriefly analyze the elements of WeChat mini programs

This article brings you relevant knowledge about WeChat Mini Program, which mainly briefly describes the principle of WeChat Mini Program. The logic layer and rendering layer of the Mini Program are separated, and the logic layer runs on There is not a complete browser object in JSCore. Let’s take a look at it. I hope it will be helpful to everyone.

Briefly analyze the elements of WeChat mini programs

[Related learning recommendations: 小program learning tutorial]

1. Essence

First of all, small programs The logic layer and rendering layer are separate. The logic layer runs in JSCore and does not have a complete browser object.

Therefore, there is no relevant DOM API and BOM API. This difference causes some libraries that are very familiar to front-end development, such as jQuery, Zepto, etc., to be unable to run in small programs.

At the same time, the JSCore environment is different from the NodeJS environment, so some NPM packages cannot be run in small programs.

In short, js is single-threaded, and the applet is dual-threaded. The logic layer and the view layer (rendering layer) are separated and run at the same time.

2. Communication

And because the applet is dual-threaded, any data transfer in the logic layer and view layer is communication between threads, so it has certain delay, so the update of the page becomes an asynchronous operation.

Asynchronous will make the running sequence of each part more complicated. For example, when rendering the first screen, the logic layer and the rendering layer will start initialization work at the same time, but the rendering layer needs to have the data of the logic layer. Only then can the interface be rendered.

If the rendering layer initialization work is completed quickly, you have to wait for instructions from the logic layer before proceeding to the next step.

So the life cycle of the mini program plays a role, as follows

3. Running mechanism

Two situations when the mini program starts and runs :


1. Cold start (restart): When the user opens the mini program for the first time or opens it again after being actively destroyed by WeChat. At this time, the mini program needs to be reloaded and started, which is a cold start. 2. Warm start: The user has opened the applet, and then opens it again within a certain period of time. There is no need to restart at this time, and only needs to switch the applet in the background state to the foreground. This process is a hot start.

【Related learning recommendations:

小program learning tutorial

The above is the detailed content of Briefly analyze the elements of WeChat mini programs. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Atom editor mac version download

Atom editor mac version download

The most popular open source editor