WordPress Performance Code Optimization

Based on years of experience we have with websites optimization we realized that it’s often ineffective code of theme or plugin or their configuration causing slowness, and it’s not effective way to workaround that by increasing hardware power.

Let’s imaging some website which is really slow. Each page loads within 10 seconds here. Ugh.. not something you want to have, people to visit and wait it to be loaded, or search engines to index.

So there are 3 types of reasons why that happens:

High traffic website

It’s rather good case to solve if website works well with 1000 visitors per hour, but starts to slow down when 10 000 visitors eventually come.

If we simlificate the problem a lot and will not talk about possible database locks / throughput limitations – it’s technically possible to just convert single webserver into a cluster of servers so that each of them will handle only a part of your visitors. Of course there are budget limitations possible, so solved easier for commerical websites when visitor means profit.

That example is widely known and shown on different webinars or like that.

But unfortunately that’s not so often case in a real world… even if our example website falls in this section, it’s very often case that budget doesn’t allow to scale enough. Let’s say it starts to slow down on 10000 visitors per day on $100/month dedicated server but we have 1M per day. It will require around 100 servers to handle this amount of visitors, so hosting services will cost at least $10 000/month + payments for that complex infrastructure maintenance.

Many commercial services may offer it, but not each website with such traffic.

Low traffic website

The problem here is that full CPU’s core and server’s disk has to exclusively work for 10 seconds to process a single page. To handle that problem via hardware only – you’ll need 10 times faster CPU and/or 10 times faster hard disk to get to a regular 1 second response time. And normally websites are not hosted on low-end hardware, so it’s very possible that such fast hardware just doesn’t exists in a commercial area so not something you are able to solve unless nuclear-reactions emulation hardware is available to you.

Have to say here that real CPU core performance sits in rather tight range now – more powerful CPU usually just contains more threads or more cores with similar performance per thread, but we need 10 times higher frequency to solve that problem!

That problem has to be solved by code optimization only.

Huge content

Website may generate each specific content rather fast in this case, but there is too much content on each page. Let’s say we have 100MB page in the end.

And surprisingly that really happens in real world, yes. Such websites transfer a lot of content which is normally hidden. Something like UberMenu with hundreds of items inside, each containing own image. Or page sections normally hidden via HTML.

Even if such content is generated appropriately – it will take more time to generate it comparing to 1MB page, plus it will take a lot of time to just transfer it via network.

That’s why it’s important to check HTML response size when theme enhanced. When grown a lot – consider to use AJAX solutions and load hidden content in a background or on-demand.


As you can see only “High Traffic Website” case can be handled via hardware / infrastructure upgrade. When it happens in ideal conditions for enough profit-generating website.

All remaining performance problems really require code and theme behavior audit, potentially plugins replacement or code changes more than your hosting plan upgrade.

That requires deep understanding of how WordPress core works and knowledge about commonly used plugins. It took years for our team to learn how to do that effectively, and that service is what differs us from regular hosting services providers.


Product-specific optimizations:

WPML plugin optimizations specifics

WooCommerce plugin optimizations specifics