{"id":25531,"date":"2020-12-25T10:11:25","date_gmt":"2020-12-25T09:11:25","guid":{"rendered":"https:\/\/inre.me\/?p=25531"},"modified":"2020-12-25T10:14:10","modified_gmt":"2020-12-25T09:14:10","slug":"guide-to-understanding-and-improving-performance-in-wordpress","status":"publish","type":"post","link":"https:\/\/inre.me\/guide-to-understanding-and-improving-performance-in-wordpress\/","title":{"rendered":"Guide to Understanding and Improving Performance in WordPress"},"content":{"rendered":"\n
An in-depth and comprehensive guide to improve the speed and performance of WordPress with actionable steps<\/strong>. We are going to see everything from the why to the how to improve speed. We are going to see both services you can use (e.g., DNS, CDN, etc.) and actions to take on WordPress (e.g. changing settings, removing plugins, etc.).<\/p>\n\n\n\n When it comes to suggestions I will try to avoid both extremes: I am not going to present 20 options and leave you to choose among a giant list of pro and cons, but I am also not just going to say pick X. I am going to explain my reasoning and provide a few good options. This way you can choose the compromise you prefer.<\/p>\n\n\n\n This guide is for people that already know how to manage a WordPress website, but do not have a deep technical knowledge, such as knowing the intricacies of the DNS protocol. It is geared toward people for which their website matters: people that may have a few websites or one that use for work. You are not going to spend thousands of dollars to improve the speed of your website, but you care enough to improve it as much as you can.<\/p>\n\n\n\t\t\t\t Speed is vital for e-commerce and large websites: for them, even a slight decrease in performance means a direct hit in revenues. If your website is slow, users are going to leave without buying. Even a small business that makes a 1000$ per day would lose 3650$ in a year, if it loses just 1% of its customers.<\/strong> This means that for such users spending a 1000$ to improve speed, even slightly, is more than worth it.<\/p>\n\n\n\n But maybe you are not there yet. So why should you care about speed? Well, at any level, low speed can affect the chances of your website to be found. Google is penalizing slow websites in their search results for 10 years<\/a>. This means that you might never get the chance to be found, if your website is not quick enough. Now they are even going to shame slow websites in Chrome<\/a>, by showing a warning while your site is loading. That is just mean.<\/p>\n\n\n\n The point is that the quicker your site is, the better will be for everybody: your users will have a better experience and you will get more users and more money. Your users will feel frustrated if you have a slow website. And they might leave it.<\/p>\n\n\n\n Finally, you have to think about helping your average user. You might have a great connection at your house, but your average user might not have one. So, if you pair their slow connection with your slow website you meet disaster. You cannot control your users, but you can control your website. Caring about your website speed is like having good hygiene, you should do the best you can.<\/p>\n\n\n\n WordPress is incredibly popular: it powers more than 33% of the top 10 million websites<\/strong>. However, it gained widespread usage because of its ease of use and flexibility, not because of its performance. It started as a blog software, but now you can use it for everything, which is part of the problem as we are going to see. Sometimes you are at fault for slowing down your website<\/strong>.<\/p>\n\n\n\n In fact, the first issue is that you might use WordPress to do everything under the sun, for your business.<\/p>\n\n\n\n You should not manage your business (e.g. using a CRM plugin) or send a newsletter directly through WordPress. You should offload anything that you can to an external service or program: loading static files, security checks, checking if all links are correct, etc. The sheer volume of cool plugins available for WordPress is amazing, but you should resist the temptation.<\/p>\n\n\n\n You should consider that it might be better to have one high-quality (and paid) plugin to do a lot of things, than a bunch of free ones. Of course this is not always true, but you have to think about any plugin you use and be sure that you need it.<\/p>\n\n\n\n You should not be a fanatic about it, there is more than just speed<\/strong>. For instance, I do not use Akismet to check for spam comments for privacy reasons. I do not want to send data about legitimate users to third-parties, unless it is necessary. You might have other needs and interests. <\/p>\n\n\n\n A more common concern is security. <\/strong>It makes sense to sacrifice some speed in exchange for better security. Even if you do not care that 60% of small businesses fold in 6 months after a cybersecurity breach<\/a>. Improving security saves you money, for the simple reason that if you block spammers and bots your website consumes less resources. This can lead to significant savings when using a service with limited included resources, like a CDN or a managed hosting.<\/p>\n\n\n\n The second big class of items that can slow your websites are the services you use to bring the content to your users. This means every component of your infrastructure: DNS, hosting, CDN, etc. There are a few things to consider for each piece of the puzzle. It is not always obvious how exactly they impact the performance of your website, but we will see how to understand that.<\/p>\n\n\n\n Obviously you know about the importance of good quality hosting, but you might not have thought about the DNS servers that answer requests for your domain. Or the side-effects of using a CDN, or services that look like a CDN (e.g., Cloudflare), but are not one.<\/p>\n\n\n\n We are going to look about each of them in detail.<\/p>\n\n\n\n Finally, you have to consider the whole WordPress setup and everything surrounding your content. In fact there is a difference between the stuff you write and the content your WordPress actually serve to the user<\/strong>.<\/p>\n\n\n\n I am not talking literally about the articles you write. Yes, it is true that if you use a lot of images this might slow down a website, but you are probably using them for a reason. No, I am talking about the real content that WordPress will serve to people: HTML, JS files, images, etc<\/strong>. What your user will receive will depend, for example, on the theme you use. A complicated and badly coded theme might send a lot of content to the user.<\/p>\n\n\n\n There are also ways to present the content better, so to speak. There are plugins you can use to reduce their size, manipulating them before sending them to the users. However, you can also use programs to optimize images before uploading them to your website, so that they are already optimized.<\/p>\n\n\n\n You should also pay attention to configure WordPress correctly to get the best performance.<\/p>\n<\/div><\/div>\n\n\n\n Now, before looking at ways to improve the speed of your website, you might consider checking whether your website is actually slow. This might be more complex than you think, because what is speed really?<\/strong><\/p>\n\n\n\n The problem is not philosophical, but practical<\/strong>: there are actually differences between technical measures and the perception of how quick your website feel to the users. And the two aspects interact in complex ways. For instance, an important technical measurement is called the Time to first byte<\/strong> (TTFB): the time it takes for your webserver to send the first byte to the client. Basically, how long it takes to the website to answer I’m here<\/em> after the user asks Are you there?<\/em><\/p>\n\n\n\n In theory the lower the number the better, but what if the webserver gives a partial answer only to appear quicker? Is it good or bad? On one hand, it is a bit deceptive because the user will need to wait more time before actually doing anything with the content. On the other hand, a lower number will avoid the risk that the browser will retry a request for the page and consume more resources.<\/p>\n\n\n\n And this is just on technical data point. The TTFB is a completely different concept from the total load time: the time it takes for the user to receive the whole content on a page. A lot could be said on each of them and they could matter in different ways for each website.<\/p>\n\n\n\n So, what should you care about? The important part is the perceived performance: how fast the website will feel to the user<\/strong>. The actual true speed is less important: a user will not gossip like an edgy teenager about your technical measurement.<\/p>\n\n\n\n Look how large their TTFB is\u2026 So what is perceived performance and how you can improve it<\/em>? There are a few well known numbers that come from a 1993 book of Jakob Nielsen, usability expert:<\/p>\n\n\n\n The basic trick of making your site feel quick is to never leave more than a few hundred milliseconds where nothing happens<\/strong>. This means actually doing something like loading content as soon as you can, and not necessarily all in one block. It also means appearing to do something like displaying a progress bar<\/strong>.<\/em><\/p>\n\n\n\n In technical terms there are many such tricks, like using animations to hide loading times<\/a> or loading the visible content first<\/a> so the user sees something as soon as possible. The big issue is that it is difficult to measure objectively how the user perceives the speed of your website. You need a bit of common sense, experience and a good designer to solve any problem found.<\/p>\n\n\n\n It is much easier to measure technical performance: that can be captured with a few numbers and tests. So, this is where most people concentrate, you can visibly improve there and show that you have done something. Now, to be clear: technical measurements of speed are not useless, the problem is that they must be understood<\/strong> in context<\/strong>.<\/p>\n\n\n\n For instance, to lower the initial perceived speed you need to have a low TTFB, so that you can show something to the user.<\/strong> The problem is once you have achieved a low TTFB you still have to understand what to show to the user<\/strong>. <\/p>\n\n\n\n Aside from the issue of what exactly to do with the test results, they can be actually hard to decipher to begin with. Even if you are a developer, you might be puzzled on what to act upon, how much effort it takes to improve and so on.<\/p>\n\n\n\n That is why I suggest starting with Pingdom Website Speed Test<\/a>. It gives you reasonably simple overview of what is happening with your website. <\/p>\n\n\n\n The most useful part of this tool are the speed results from different places. You can measure the performance of your website from users in London, Sydney, San Francisco, etc. And you get a simple score and load time<\/strong>. It is easy to understand if you have any real issue on your hand.<\/strong><\/p>\n\n\n\n As you can see, the score (performance grade) and the load time are actually telling two different things:<\/p>\n\n\n\n You can get one good result and one bad result. You will also obviously get different load times depending on the region you test. As we said, you cannot really say if a load time is good or bad just from this number. However, since I know you need an answer, generally speaking you should strive for under 3 seconds for the majority of your audience<\/a>.<\/strong><\/p>\n\n\n\n Now, if you are serious about speed, remember that you cannot cheat. It is relatively easy to get under 2 seconds on a sparse homepage, it is harder to get that result for a giant long-form article with 10K+ words and lots of images. Of course, the users might be forgiving in exchange to access useful content, but maybe not.<\/p>\n\n\n\n If you get a good performance grade and a bad load time, your problem is probably due to your infrastructure and the fact that you put too much stuff on your website. If you get a bad performance grade, you should start looking at the whole WordPress setup.<\/strong><\/p>\n\n\n\n Now, if you need to work on your performance grade you must be ready to get deep into technical details. You should take time to understand each element and ditch this tool.<\/p>\n\n\n\n Instead you should go to the Page Speed Insights of Google. <\/a>You can also access this tool, and more, if you use the Developer Tools<\/em> in Chrome and specifically the Audit<\/em> section. This is the best way to use it, if you plan to seriously work on your website as a developer.<\/p>\n\n\n\n First, you should use this tool because is the foundation of all others. It is a Google world; we just live in it. So, other tools, like the Pingdom one or the also well known GT Metrix<\/a>, are based on what Google says. This also means that other tools might have obsolete suggestions. The point is not that Google is always right, but they are going to follow their own rules and possibly penalize your search result if you do not follow them<\/strong>.<\/p>\n\n\n\n The other reason to use this tool is that it can give you real data based on users of Chrome<\/strong>. So, you can know the technical performance of your real users. Now keep always in mind that having a score of 100 even on Google’s tool should not be your objective. For one, it might cost a lot of effort or a bad user experience. This image shows that Reddit does not have good results, yet they are doing fine<\/strong>. Even YouTube<\/a>, that is owned by Google, does not have great results. It is meant to be used as a guideline. Furthermore, the tool itself also is slower to follow the official Google suggestions. <\/p>\n\n\n\n For example, I remember that the tool still showed as an issue having too many HTTP requests, when the official line was changed with the new protocol HTTP\/2. This is not a big problem anymore, since the new protocol makes many small requests preferable to a few large ones, because they can be made in parallel.<\/p>\n\n\n\n The last good thing about this tool is that it gives you some pointers both for your mobile and desktop traffic<\/strong>. You have to remember to test and optimize both for desktop and mobile devices. Nowadays mobile traffic is around 50% of the traffic<\/a> on the internet. Obviously, it may be less important for your specific website (e.g., a site dedicated to long-form expert articles), but that is the general rule. And mobile and desktop browsers have different behaviors and constraints, so you have to pay attention to both.<\/p>\n\n\n\n Finally, we are going to end this introduction with an important distinction: your average content-based website is different from a more dynamic website<\/strong>, like an e-commerce or forum.<\/p>\n\n\n\n It is easier to speed up a typical WordPress website like this one, that is mainly used to show articles to the user. The content is mostly static, so it can be fully cached. And users interact with it sparingly and for little bursts of time: they find an article and they read it. Then they read another article, or they leave.<\/p>\n\n\n\n This is different from websites that provide a service<\/strong>. In the case of WordPress installations, it means e-commerce websites, sites that host video courses, forums, etc. In the general case this also includes websites like Google or Facebook, that provide dynamic content to the user. <\/p>\n\n\n\n These websites are harder to speed up<\/strong> because caching is less effective. Users might stay for long periods of time, even hours at a time. They can interact frequently, placing orders, answering to comments, etc. Therefore, the average dynamic website will be slower. Apart from losing users and sales, excessive slowness might lead to lower quality interactions (i.e., a user posts something multiple times, because clicking the button You must start to improve speed by choosing the right hosting. It is the one thing upon which everything else depends. You need a good host for your website, then you can change everything else. It is obviously possible to change hosting but is an hassle and it takes some work to do it without downtime. So, choose right the first time.<\/p>\n\n\n\n I would say that there are fundamentally three types of hosting, that are different for reliability, performance, ease-of-use and support<\/strong>:<\/p>\n\n\n\n Choosing the appropriate hosting for your need and budget is vital, not just for performance. Did you know that 41% of all hacked WordPress installations were violated due to their hosting<\/a>?<\/p>\n\n\n\n Shared hosting is usually where you start because is the cheapest type of hosting<\/strong>. You can usually host not just WordPress websites, but also any other PHP software or even Node.js apps. You can recognize them by the promise of unlimited bandwidth<\/em>. So, it is cheap and flexible, which is great. However, it does not have good performance. Even worse, any performance you have is not really stable.<\/p>\n\n\n\n The problem is that your website shares the same server with many other ones, so if the other ones get a spike of visits or get hacked, your website will feel it. In practice, this means that you cannot realistically measure your performance, therefore you cannot improve it. The company will manage their platform only in the sense that they will kick out bad websites, one that consumes too much resources. This seems fair, but what happens is that if you get hacked you will get no support and you will just be left in the cold.<\/p>\n\n\n\n Lastly, they tend to have some arguably shady business practices: you get a great first price, then a less-good renewal price. To be fair, they do not hide it<\/span>1<\/sup><\/a><\/span>. However, they do that because they could not make any money otherwise. If you want to get the best price, you might also be hooked to long contracts.<\/p>\n\n\n\nWhy Speed is Important?<\/h2>\n\n\n\n
What is Slowing Down your Website?<\/h2>\n\n\n\n
You Are the Baddie<\/h3>\n\n\n\n
The Infrastructure You Use<\/h3>\n\n\n\n
Your WordPress Setup<\/h3>\n\n\n\n
Is Your Website Slow?<\/h2>\n\n\n\n
Your Website Must Feel Quick<\/h3>\n\n\n\n
Ugh! Why that website is even talking to me<\/p><\/blockquote>\n\n\n\nReal Speed Still Matters<\/h3>\n\n\n\n
Measuring Speed<\/h3>\n\n\n\n
Working on Your Technical Performance<\/h3>\n\n\n\n
Not All Websites Are the Same<\/h2>\n\n\n\n
Comment<\/code> does not seem to do anything<\/em>).<\/p>\n<\/div><\/div><\/div>\n\n\n\n
Hosting<\/h2>\n\n\n\n
Types of Hosting<\/h3>\n\n\n\n
Shared Hosting<\/h4>\n\n\n\n