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.
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
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
Reduce Cookie
Do not include cookies in the domain name of imported resources
Put the style sheet to the top
Do not use CSS expressions
Do not use @import
Do not use IE’s Filter
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
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
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!