Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Front-end performance optimization method

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1. Reduce the number of http requests

There are several common ways to reduce the number of http requests:

1) merge pictures. When there are many pictures, they can be merged into one large image, thus reducing the number of http requests. Pictures that change frequently may not be appropriate, and those with relatively stable changes can be considered.

2) merge compressed css stylesheets and js scripts, their common goal is to reduce the number of http connections.

3) remove unnecessary requests. Develop invalid request connections that remain after writing code or system upgrades.

4) make full use of the cache. The cache here is client-side cache or browser cache. Expires header information is an important basis for client-side caching. The format is similar to Expires:sun, 20 Dec 2017 23:00:00 GMT. If the current time is less than the time specified by Expires, the browser will obtain the relevant data information or html file directly from the cache. If the current time is greater than the time specified by Expires, the browser will send a request to the server to obtain the relevant data information.

Take Apache as an example, you can set Expires in the configuration file httpd.conf of Apache.

two。 Picture optimization

Optimization method:

1) use the PNG format as much as possible, which is relatively small.

2) for images in different formats, it is best to optimize them before launching.

3) delayed loading of pictures, also known as Lai loading.

3. Use CDN

CDN is the content distribution network, which can enable users to get the content they need nearby, solve the situation of network congestion, and improve the response speed of users visiting the website.

4. Turn on GZIP

GZIP is data compression, which is used to compress all text resources transmitted using Internet. The way to enable GZIP is simple, just set it in the corresponding web service configuration file. Take Apache as an example, add it to the configuration file httpd.conf.

5. Optimization of style sheet and JS file

We usually put the css stylesheet file in the header of the file. For example, put it in a tag so that the CSS stylesheet can be downloaded as soon as possible. For the js script file, we usually put it at the end of the page.

6. Use a domain name without cookie

No cookie domain name concept: when sending a request, but also to request a static image and send cookie, the server will not do any use of these cookie, that is, these cookie are useless, do not send with the request.

7. Optimization of front-end code structure

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report