Several ways to optimize WordPress:
1. Separation of dynamic and static resources
Source The website server mainly stores the dynamic data of the website, and the storage space is used to store the static files of the website such as pictures, css, js, fonts, etc. This achieves the separation of dynamic and static websites. When a user visits a website, data is read synchronously from the origin server and the storage space server, which can greatly improve web page performance.
At the same time, the storage space is used in conjunction with the CDN content distribution network, which has the best effect. Allow users to obtain static resources from the CDN node closest to them.
2. Image optimization
Generally, the size of images may account for more than 60% of the total page size. Therefore, the optimization of website images is the top priority for website speed optimization. In terms of the format of website pictures, it is recommended to use jpg format pictures first. In the case of the same file size, jpg format pictures have the best clarity.
In addition, before uploading the picture, crop it as much as possible. Generally, 1000*1000 is enough. In addition to cropping, be sure to use a lossless compression tool to compress your images before uploading them. For example:
Google launched the online image compression tool Squoosh, which can crop and convert multiple formats
At the same time, if you find it troublesome, you can install the Compress JPEG & PNG images plug-in, which can crop overly large images while uploading and compressed images. Recommended: How to compress images in WordPress
3. Cache
WP Super Cache achieves static acceleration of the entire site by generating static HTML files from web page files.
Opcode "PHP Cache Acceleration", the intermediate files compiled by PHP are cached for user access. It saves the time of repeated compilation of the PHP engine, reduces the server load, and reduces the CPU and memory overhead.
4. CSS, JS compression and merging
On the premise that there are no problems in the test, merge and compress scripts, CSS files, JS files, etc. to reduce the file size and the number of HTTP requests. For example: Plug-in Autoptimize
5, enable Gzip compression
Enabling GZIP compression of Html files, css, and js can greatly reduce the traffic during the transmission process and accelerate the loading speed of the website.
Check whether your website has compression turned on? https://www.giftofspeed.com/gzip-test/
6. Simplify "Breaking Away"
Simplify the less commonly used WordPress fonts, Google fonts, disable emoji, and remove headers Unnecessary links, etc.
Reduce the use of plug-ins, disable or promptly delete unused plug-ins.
7. Browser cache and lazy loading
Browser cache refers to: when we browse the website, static resources such as JS and CSS files, image files, etc. will be stored in the browser Store a copy locally so that the next time you visit the same URL, you can no longer connect to the server and use the local cache directly. The server-side program can set a longer cache expiration time through HTTP Cache Headers, reducing the burden on the server, shortening the response time, and significantly improving the performance of the website.
Delayed loading of images is also called lazy loading. Lazy loading means waiting until the image appears in the browser window before loading the image resource. This prevents the webpage from loading too many resources at the same time, causing the page to freeze, thereby directly improving the webpage opening speed. Nowadays, general themes may support lazy loading of images. If not, you can install a lazy loading plug-in such as a3 Lazy Load.
8. Try to upgrade the server software to the latest version
Linux operating system upgrade command: yum update
PHP7.3 has a very significant improvement in website performance, and both It is supported by real data.
The same goes for Nginx, MariaDB, etc. I have 1G of memory and it can run very well.
For more wordpress related technical articles, please visit the wordpress tutorial column to learn!
The above is the detailed content of how to optimize wordpress. For more information, please follow other related articles on the PHP Chinese website!