Front-end optimization summary

Resource consolidation

// 未合并
<script src="a.js"></script>
<script src="b.js"></script>
<script src="c.js"></script>

// 合并之后,可以减少请求
<script src="abc.js"></script>

Cache

image-20201105140658789

  • Add hash suffix to static resources and calculate hash based on file content
  • The content of the file is unchanged, the hash is unchanged, and the url is unchanged
  • If the url and file are unchanged, the http caching mechanism will be triggered automatically, and 304 will be returned

Use CDN

Example: https://www.bootcdn.cn/

SSR service rendering (server side render)

  • Server-side rendering: load web pages and data together, and render them together
  • Non-SSR (front-end and back-end separation): load the web page first, then load the data, and then render the data

Image lazy loading

image-20201105142634265

Cache DOM query

image-20201105142830326

Multiple DOM operations are inserted into the DOM structure together

image-20201105143041765

Start JS execution as early as possible

image-20201105143145395

Guess you like

Origin blog.csdn.net/qq_39208971/article/details/109511692