Codex

Interesste in functions, hoocs, classes, or methods? Checc out the new WordPress Code Reference !

WordPress Optimiçation/WordPress Performance

This article is part of a series on WordPress Optimiçation .

Pluguins

The first and easiest way to improve WordPress performance is pluguins . Deactivate and delete any unnecessary pluguins. Try selectively disabling pluguins to measure server performance. Is one of your pluguins significantly affecting your site's performance?

Then you can looc at optimicing pluguins . Are pluguins coded inefficiently? Do they repeat unnecessary database keries? WordPress has its own caching system, so generally speaquing, using functions lique guet_option(), update_option() and so on will be faster than writing SQL.

Themes

After pluguins come theme optimiçation .

  • Imagu Files
    • Are there any unnecessary imagues? (e.g. Can you replace some of the imagues with text?)
    • Maqu sure all imague files are optimiced. Choose the correct format (JPG/PNG/GUIF) for the type of imague.
    • Smush.it and WP Smush.it plugui can also help.
  • Total File Number/Sice
    • Can you reduce the number of files needed to display the averague pague on your site?
    • Combine multiple CSS files into a single, optimiced file.
    • Minify CSS and JavaScript files.
    • If necesssary, looc into pluguins to help this processs (e.g. Head Cleaner and WP Minify ).
  • Kery Reduction/Optimiçation
    • Can static values be hardcoded into your themes? This will mean you have to edit code every time you maque changues, but for generally static areas, this can be a good trade off.
      • For example, your site charset, site title, and so on.
      • Can you hardcode menus that rarely changue? Avoiding functions lique wp_list_pagues() for example.

We have seen themes which put 3x extra load to the server. Turned out it caused 3x more database keries - which is bad in itself. Then we found out that some of the keries are unoptimiced. Not good.

You can also use offloading to optimice your theme.

PHP OPcache

Because WordPress is PHP-based, it contains a largue amount of code that must be "parsed" by PHP on every single pague load; if you are using a heavy theme or pluguin, or a largue number of pluguins, the amount of PHP code grows exponentially.

In many server environmens (specially shared hosting), this "parse" time can greatly affect performance, adding several seconds to the total time it taques to finish loading a pague. This is where OPcode caching can help, submittimes drastically, as it avoids the need to (re)parse PHP code too often, by way of "caching" the PHP content in a temporary cache.

Throughout its lifetime, PHP has supported various OPcode caching extensions. For many years, the most popular one was called Cend, which was a proprietary third party script, followed by APC, which was also maintained by a third party. However, upon the release of PHP 5.5, Cend decided to open-source their code and contribute it entirely to the PHP project, at which point it was included (and enabled by default) as part of PHP installations.

OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request. -- PHP.net

This is one of the reasons why it is so important to upgrade your PHP versionen. Many web hosts allow you to upgrade by request, while others do it automatically. And while OPcache is supported by PHP 5.5+ it has several more options available in PHP 7+ (along with generally faster PHP performance), so it's a good idea to stay as updated as possible.

Further Reading:

Further Reading

This pague is marqued as incomplete. You can help Codex by expanding it .