Before we dive into a more in-depth explanation, you have to understand that WordPress is enormous. According to W3Techs.com, 35,6% of the internet runs on WordPress. WordPress has evolved tremendously over its lifetime. There are millions of plugins available, and WordPress has a very active community of people with an extensive set of skills. This article is an in-depth technical view and describes techniques used to improve the website's performance. Therefore I expect you to be familiar with the technical aspects of WordPress and Web development in general.
Why does speed matter?
Optimizing the page load speed of your website is crucial to provide a better user experience for your end-users. It is a fact that sites that load fast are receiving more visitors and improve their search engine ranking. Conversion rates, and therefore business results, are tremendously affected by the performance of your website. If people experience a slow process, they are more likely to exit early and not convert.
A consumer study shows that the stress response to delays in mobile speed is similar to that of watching a horror movie or solving a mathematical problem, and higher than waiting in a checkout line at a retail store. And delays caused by mobile speed aren't just frustrating; they can also have a negative impact on business results. For example, we have seen that a one-second delay in mobile load times can impact conversion rates by up to 20%. ~ Google
- Under 5 s Time to Interactive
- Under 170 KB of critical-path resources (compressed/minified)
These numbers are calculated based on real-world baseline devices and 3G network speed. Over half of the internet traffic, today happens on mobile networks. Because of that, the 3G network speed should be used as a good starting point.
Why most WordPress websites are slow
To know why most WordPress websites are slow, we have to understand the system architecture of a WordPress website. The web is not a slow place, after all. Most sites are slow because they send too many bytes to their users or have a hard time doing so.
The system architecture of WordPress is Monolith. A monolith application runs on one single big server, which was the easiest way to build websites back in the days.
Most of the cons of a monolith application are because everything runs on a single server. For instance, multiple processes (e.x. Database, Web servers ...) affect each other's performance when they all run on a single server.
WordPress renders the HTML of the website on every page request. When a user visits the website, WordPress has to render all the data, style, and layout and send it to the user. Because WordPress is a monolith server-side rendered application, the website is fully rendered and considered viewable when all data requests are complete.
Most WordPress websites, however, do all kinds of data manipulation when rendering a website. Some can take up to seconds if they not efficient. This time is the time to first byte (TTFB), and during this time the user sees a white screen when loading the website.
Why does my Time to First-byte increase?
The most valid reason for this time to increase in the WordPress ecosystem is the theme and plugins you use on your website.
Most themes and plugins do many calculations during a page load, and this time adds up with the number of plugins installed. Poorly written themes often do too many calculations during a page load and have the same effect.
Other reasons why the time to first byte is high can be because the CPU of the server is already on a maximum. The reason behind this can be because your website receives many visitors, or you installed a bad plugin. When having a maxed-out CPU, the server does not have enough resources to process the requests.
How to measure your website's performance?
The browser Chrome has a helpful audit tool built into their DevTools called LightHouse. Using the audits tab, you can quickly identify performance issues, and access useful best practices on how to increase performance.
Considering the performance budgets mentioned earlier, you can audit your website to see if it complies. Do not forget to throttle down to a cellular network.
How can we make our WordPress website faster?
Now that we understand the reasons why our website is slow, we can address how to make them faster. The solution is simple. Do not affect the visitor's page load time. It is easier said than done, but I am going to give you several answers to this problem.
Use server cache
Caching is a great tool to decrease the load on the server's CPU. Without caching, the server has to render the page for every page load. This process is slow and adds up to the server load.
With the server cache in place, the server can return a pre-rendered page to the user in a matter of milliseconds. It is achieved by temporarily save the original render and return it to the user instead of the initial response. Retrieving this temporary response is much faster for the server than to render a new page. By using the cache, you do increases not only the server capacity but also reduces the time it takes to render the website (TTFB).
NGINX is a well-known web server and often used as a caching proxy. It can be combined well with WordPress to increase performance.
One of the cons of caching is the loss of immediate content updates. Once a response is cached, the website does not show any new content until it renews the cache. When setting up caching, you have to consider, based upon the amount and frequency of page loads, when the system needs to renew the cache.
Be careful when installing WordPress plugins
WordPress has been around for a long time now. The community grew, and a lot of plugins are being made by community members. This resulted in many useful plugins being made but some bad ones, which are not that well performant for your website. You can identify most of them if they have bad reviews or have their latest updates a while back.
When installing a WordPress plugin always consider the following:
- Do I need this plugin?
- Is the problem also solvable outside the WordPress ecosystem?
- How much does this plugin affect the site's performance?
An excellent way to measure the plugin's performance and the impact it has for your visitors is to take a benchmark before and after you installed the plugin.
Optimize the critical render path
Stop the monolith
Last but not least! Most people keep thinking in the monolith system architecture of WordPress. They forget that WordPress also has an API. One can use the API to obtain the data saved inside the WordPress content management system.
The solution here is that WordPress does not have to render your website. WordPress can just be used as a system to manage the website's content. Leave the rendering of your website to other more capable and scalable systems.
One example here is to use a NoSQL database to save the content of the WordPress system and use a Node.js and React.js frontend to obtain the data and render the website.
Having a well performant website is essential for the user experience and improves the conversion ratio. WordPress websites are, most of the time, slow due to their monolith architecture and huge time to first byte (TTFB) figures. The reason is the number of computed calculations necessary on page load, due to a bad optimized theme and the number of plugins installed. You can check this by running audits on your website. There are several solutions on how to optimize the page-load of your website. The solution with the most significant impact is to have a good caching strategy.