This is for the record 前端面试的话术集锦第七篇博文——高频考点(浏览器渲染原理 & 安全防范)
and I will keep updating this blog post. ❗❗❗
1. Browser rendering principle
Note: This chapter is a face-to-face examination question.
1.1 Rendering process
1.1.1 The browser receives the HTML file and converts it into a DOM tree
When we open a web page, the browser will request the corresponding HTML
file. Although we usually divide them into JS
, CSS
, and HTML
files when writing code, that is, strings, computer hardware does not understand these strings, so the content transmitted on the network is actually 0
these 1
byte data. When the browser receives these bytes of data, it will convert these bytes of data into strings, which is the code we write.
When the data is converted into strings, the browser will first convert these strings into tokens ( token
) through lexical analysis. This process is called tokenization ( tokenization
) in lexical analysis.
So what is a mark? This actually belongs to the content of the compilation principle. To put it simply, a token is still a string, which is the smallest unit of code. This process will split the code into chunks and mark these contents, so that it is easy to understand what these smallest units of code mean.
When the tokenization is completed, these tokens will be converted into Node
, and finally these Node
will Node
be constructed into a tree according to different previous connections DOM
.