Front-end performance optimization

After developing the page, how to make the page run better and faster

From a front-end perspective, performance can be split in two directions

From the user's point of view, one is that the page loads quickly, and the other is that the page is very smooth to use

url entered

Browser starts parsing > query local cache > dns parsing > establish connection > server processing > server response > client receives response > parses html > then starts rendering page > user can interact > loading complete

1. Minimize HTTP requests

Merge images, merge css, js

2. Use a CDN

3. Specify Expires or Cache-Control for the file header to make the content cacheable

To avoid sending the http request again in the future

4. Avoid empty src, and href

5. gzip for compression

6. css is placed in the head

Very important for users with a lot of content and slow internet speeds

7. Reduce the number of dns queries

8. When using AJax, if the security requirements are not high, when the url is less than 2k, use get and post in two steps, first send the file header, and then send the data.

9. Preloading, lazy loading

10. Avoid redirects as two requests are made

11. Adopt event delegation, bubbling principle


Guess you like

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