Home > Common Problem > body text

How to optimize website performance

hzc
Release: 2020-06-28 14:06:24
Original
4598 people have browsed it

Website performance optimization includes: 1. In terms of content, reduce HTTP requests, reduce DNS queries, and avoid redirects; 2. In terms of server, use CDN, use Gzip compression, and avoid empty src img tags; 3. In terms of cookies, reduce cookies.

How to optimize website performance

1. Content aspect

Reduce HTTP requests: merge files, CSS sprites, inline images

Reduce DNS query: The browser cannot download any files from this host before the DNS query is completed. Methods: DNS cache, distribute resources to an appropriate number of host names, balance parallel downloads and DNS queries

Avoid redirects: redundant Intermediate access

Use AJAX caching

Lazy loading of non-essential components

Preloading of future required components

Reduce the number of DOM elements

Place resources under different domains: The browser can download a limited number of resources from one domain at the same time. Adding domains can increase the number of parallel downloads

Reduce the number of iframes

Don’t 404

2. Server aspect

Use CDN

Add Expires or Cache-Control: When Cache-Control and Expires exist at the same time, Cache-Control will overwrite Expires. Related links

Use Gzip compression

Configure Etag

Flush Buffer Early

Ajax uses GET for requests

Avoid empty src img Tag

3. Cookie aspect

Reduce Cookie

Do not include cookies in the domain name of imported resources

4. CSS aspect

Put the style sheet to the top

Do not use CSS expressions

Do not use @import

Do not use IE’s Filter

5, JavaScript

Place the script at the bottom of the page

Introduce JavaScript and CSS from the outside

Compress JavaScript and CSS

Delete unnecessary scripts

Reduce DOM queries

Reasonably design event listeners

6. Picture aspects

Optimize pictures: Select color depth according to actual color needs. Compression

Optimize CSS sprites

Do not stretch images in HTML

Ensure favicon and ico are small and cacheable

7. Mobile aspects

Guarantee components are less than 25K

Pack Components into a Multipart Document

The above is the detailed content of How to optimize website performance. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!