当前位置:网站首页>Rookie colleagues cost me 2K. Did you recite the secret of salary increase? (collect it quickly!)
Rookie colleagues cost me 2K. Did you recite the secret of salary increase? (collect it quickly!)
2022-07-24 18:25:00 【Front end goose】
List of articles
- One How to optimize the white screen time when loading for the first time ?
- Two How to avoid layout jitter ?
- 3、 ... and fictitious DOM And the actual DOM What's the difference? ?
- Four From input URL Show to page , What happened in the middle ?
- 5、 ... and DOM How trees are made ?
- 6、 ... and DOM During parsing style And script How is the label handling different ?CSS Will it block the page ?
Inadvertently know rookie colleagues The salary is higher than me 2k, puzzled , torture ( Push the cup for another one ) between , Finally came up with the secret , Turned out to be interview front Recite these
Interviewers call experts directly , Hire immediately .
Acid Na !
present Disgusting finishing as follows , The information that cost a lot of money is here , Hurry to collect !!!
One How to optimize the white screen time when loading for the first time ?

Usually, the optimization is mainly reflected in downloading CSS file 、 download JavaScript File these key resources , And execution JavaScript Blocking problems caused by .
1.1 Minimize file size
Minimize file size , Such as through webpack Wait for the tool to remove some unnecessary comments , Yes CSS and JavaScript Compress resources .
1.2 Reduce the number of critical resources
Put some that don't need to be parsed HTML Used in stages JavaScript On the mark async perhaps defer, bring js And html Parallel download .
Big CSS file , You can query the properties through the media , Divide it into several different uses CSS file , In this way, only in a specific scenario will specific CSS file .
1.3 CDN To reduce the number of times RTT Duration
CDN It is an intelligent virtual network based on the existing network , Rely on edge servers deployed everywhere , Load balancing through the central platform 、 content distribution 、 Scheduling and other functional modules , Let users get the content they need nearby , Reduce network congestion , Improve user access response speed and hit rate .
RTT Namely FTP Request round trip delay . It is an important performance index in the network , Indicates that data is sent from the sender , Receive confirmation from the receiving end to the sender , Total time delay experienced .
Two How to avoid layout jitter ?
Iterate through the code dom Operation will cause rearrangement and redrawing , Cause layout jitter , For this, you can mount all the elements to a dom On the fragment , Collective mount .
stay vue And other modern frameworks have generally passed the virtual dom Trees solve this problem .
At this time, the interviewer is getting better , At first glance, you know a lot , Ask questions quickly .
3、 ... and fictitious DOM And the actual DOM What's the difference? ?
This problem belongs to Hide the eggs ah , Need the foreshadowing of the last answer , Open your mouth , More 200 block , There are pancake fruits .
fictitious DOM, By reducing the perception of reality DOM Tree modification , Thus reducing rearrangement and redrawing .
The changed content of the page is first applied to the virtual DOM On , fictitious DOM When enough changes are collected , Then apply these changes to the real DOM On .
You can see , fictitious DOM The tree is like a cache .
When the model data changes , Generate new virtual DOM, With the previous virtual DOM Compare , Find the changing nodes , Apply changing virtual nodes to DOM On , Trigger DOM Node update .
Four From input URL Show to page , What happened in the middle ?

- The browser process received a user input URL After the request , take URL Forward to the network process . Launch real URL request .
- The network process sends a request ,TCP Request a response , Received response header data , Parse the response header data , And forward the data to the browser process .
- The browser process received a response header , send out “ Submit navigation (CommitNavigation)” Message to render process .
- The rendering process receives a message , Start receiving HTML Data preparation , The way to receive data is to directly establish a data pipeline with the network process .
- The rendering process will return a message to the browser process , Tell the browser process :“ Ready to accept and parse page data ”..
- The browser process will receive HTML Submit the data to the rendering process .
- The rendering process returns a message to the browser process after rendering .
- The browser process received the message , Start removing old documents , Then update the page status in the browser process .
5、 ... and DOM How trees are made ?

Inside the rendering engine , One called HTML Parser (HTMLParser) Module , Its duty is to be responsible for HTML Byte stream converted to DOM structure .
HTML The parser maintains a stack structure , This stack is mainly used to calculate the parent-child relationship between nodes ,html Nodes will be pushed into this stack in order .
When parsing starts, it will automatically press document Start label node of , After parsing, press document End label node .
This process is similar to bracket matching , Output a complete node by finding the matching parentheses in the stack .
arr = ['{','(',')','}']
Above . When matching to ’)‘ When to find a child node ,‘()’ yes ’{}' Child nodes of .
HTML The parser does not wait until the entire document is loaded , It's how much data the network process loads ,HTML How much data does the parser parse .
6、 ... and DOM During parsing style And script How is the label handling different ?CSS Will it block the page ?
Resolved to <script> When labeling , The rendering engine judges that this is a script , here HTML The parser pauses DOM Parsing , download JavaScript Code and execute , After execution , The parser resumes the parsing process , Continue to parse the following , Until the final DOM.
CSS Will block the display of the page , When calculating styles, you need to wait css File resources are cascaded . Resources are blocked , Will wait , Until the network times out ,network Report the corresponding error directly , The rendering process continues the cascading style calculation .
( Net friend : Ouch , Remember , I feel like I'm worth more ! I forgot what to do during the interview ?)
hurriedly Collection ah ! Take it out during the interview Peek at !
边栏推荐
猜你喜欢

Sword finger offer 21. adjust the array order so that odd numbers precede even numbers

5. Reference type and value type as function parameters?

Shanghai Jiaotong University team used joint deep learning to optimize metabonomics research

【刷题记录】20. 有效的括号

Mysql——》BufferPool相关信息

Typora is still the most beautiful and beautiful document editing artifact of yyds in my heart. I believe you will never abandon it

EasyUI framework dialog repeated loading problem

CF. Bits And Pieces(子集状压dp + 剪枝)

About the writing method of interface 1 chain interpretation 2. Method execution (finally) must be executed

["code" power is fully open, and "chapter" shows strength] list of contributors to the task challenge in the first quarter of 2022
随机推荐
Number of times a number appears in an ascending array
空间三点画圆代码
JS to achieve progress steps (small exercise)
Framework introduction
CF lomsat gelral (heuristic merge)
Growth of operation and maintenance Xiaobai - week 8 of Architecture
树链剖分板子
About the writing method of interface 1 chain interpretation 2. Method execution (finally) must be executed
无关的表进行关联查询及null=null条件
Latex数学公式
Encapsulate function basedata.js
Install jumpserver
odoo中的bom理解
Section 10 cache breakdown follow Daewoo redis ------- directory post
Windowing function (1) - top three employees of department salary
Icml2022 Best Paper Award: learning protein reverse folding from millions of predicted structures
Go language interface and type
jmeter -- prometheus+grafana服务器性能可视化
ORM introduction and database operation
初识Pytorch和Pytorch环境配置