How to Optimize WordPress for Better Performance

WordPress is amazing an amazing App. It started off as a simple blogging platform and turned into the world’s most used Content Management System, with over 10,000 themes and thousands of plugins extending its functionality.

With that kind of flexibility comes certain issues, namely, WordPress can become slower the more you try and expand its functionality. But, there are ways to improve performance and optimize WordPress.

Here’s our step by step guide on how to improve the performance of your WordPress website. If you’d rather not do these steps yourself, you can sign up to our Managed WordPress service, where you get a management layer on top of WordPress and LiteSpeed that takes care of performance issues for you automatically.

Step 1. Speed

Google PageSpeed service is an exceptional tool that helps you measure your WordPress website’s performance and receive precise, definite feedback on how to make improvements.

Ideally, your website should load between 2 and 5 seconds. We won’t go in-depth on Google PageSpeed since it’s a complex service; however, here’s a quick breakdown of each section it shows:

  1. Lighthouse score – Right beneath the rating of your website, you’ll see some numbers which represent the speed of your website. You can read more about the scoring system here: https://developers.google.com/web/tools/lighthouse/v3/scoring
  2. Lab data – This section shows speed tests related to network, CPU, and other measures.
  3. Opportunities – Data in this section provides suggestions to improve your page speed.
  4. Diagnostics – Suggestions on how to improve the speed of your application.
  5. Passed audits – Tests that were successfully passed by your website.

Additionally, you can use these third-party services to compare results with the PageSpeed tool:

http://yslow.org/
https://www.webpagetest.org/
https://www.pingdom.com/

Step 2. WordPress

Updates

WordPress is an open-source project, so it’s updated frequently. These updates introduce new features but also fix bugs, issues, memory leaks, and so on. This is why it’s essential to always keep your WordPress and its plugins and themes up to date. Not doing that may make your website vulnerable, slow, and unreliable.

Plugins

Having a lot of unnecessary or outdated plugins is likely the most common cause of a sluggish website. Poorly coded plugins will load a lot of bloat that is not needed for your website and thus slow it down tremendously.

Here are some of the rules you should follow:

  • Deactivate and delete any unnecessary plugins.
  • Turn off settings you don’t utilize in some of your plugins.
  • Never duplicate functionality with plugins (for example, don’t use two plugins for the same SEO features).
  • Run a speed test before and after installing a new plugin to see how it will affect your site.
  • Make sure only to use popular plugins. You can see if the plugin is compatible with your version of WordPress when you go to install it.

Here’s a list of some slow plugins we’ve detected through our use:

  1. AddThis
  2. Social Discussions
  3. Socialable
  4. Similar Posts
  5. All-In-One Event Calendar
  6. Backup Buddy
  7. WPML
  8. Yet Another Related Post Plugin
  9. Beaver Builder
  10. Better WordPress Google XML Sitemaps
  11. Constant Contact for WordPress
  12. Sharebar
  13. ShareThis
  14. Share Buttons by AddToAny
  15. Share Buttons by E-MAILiT
  16. Contact Form 7
  17. Contextual Related Posts
  18. Essential Grid
  19. Facebook Chat
  20. Google Analytics
  21. Jetpack
  22. NextGEN Gallery
  23. Really Simple Share
  24. Reveal IDs
  25. Revolution Slider
  26. ShareThis
  27. WP Facebook Like Plugin
  28. WP Social Bookmarking Lite
  29. WP Social Share
  30. Tribulent Slideshow Gallery
  31. Ultimate Social Media & Share
  32. VaultPress
  33. WooCommerce Customer History
  34. WordPress Facebook
  35. WordPress Related Posts
  36. WordPress Popular Posts
  37. WordPress Social Ring
  38. WP Bakey (formerly Visual Composer)

On our Managed WordPress platform, we did the work for you by blocking certain plugins due to known security issues or simply because they are outdated.

You can also use GTMetrix’s Waterfall view to find slow plugins by hovering your mouse cursor over the entries.

Themes

Once you have followed our advice on plugins, the next thing to look at is the theme you’re using. Same as with plugins: delete inactive themes and only use themes that are regularly updated by the theme author.

Note that most of the beautiful and complex themes are poorly coded and contain a ton of elements that can slow down your website. It’s usually better to go with a more straightforward theme that doesn’t have unnecessary features or complicated layouts as you can always build those features using quality WordPress plugins.

Step 3. Optimization

Background Processes

Scheduled posts and updates won’t slow down your website, but it is essential to keep an eye on the backup plugin you use and search engine crawlers. Make sure your backup plugin only runs during low traffic times on your website and adjust daily backup to a couple of days per week if you don’t post new content daily.

For search engine crawlers, make sure to often check crawl reports in Google Search Console, as crawls that hit an error can cause a slowdown.

Excerpts

WordPress shows the full content of the article/post by default, and it can slow down your homepage and archive pages. We recommend you enable only excerpts on your archive pages to speed up the loading times. You can do that from the Settings > Reading section by selecting “For each article in a feed, show: Summary” instead of the “Full Text” option.

Comments

It’s fantastic if you have tons of comments on your posts, but these affect the loading speed of those posts. It’s recommended to split comments into multiple pages by going to Settings > Discussion section and enable the “Break comments into pages” option.

We also recommend disabling Gravatars, especially if you have a lot of comments, as they will take a long time to load. There are a couple of options you can use:

  • Host Gravatars locally on your server using the WP User Avatar plugin
  • Set the default Gravatar to blank
  • Disable Gravatars outright
  • Limit the Gravatar images to a small dimension

Audio/Video files

WordPress automatically displays uploaded video and audio files in an HTML5 player, but playing these will utilize a ton of bandwidth. We recommend to upload your audio or video files to Youtube, Vimeo, or SoundCloud and then simply embed them on your website. Since WordPress has built-in embed feature – it will save both server resources and your bandwidth.

Pages

Use Google Analytics to find slow pages and recommendations for them from left-hand menu > Behavior > Site Speed > Speed Suggestions:

Disable WP-Cron

Using system cron-job service will always improve performance over WordPress cron (WP-Cron), so you might consider disabling it as per the article here.

Step 4. Caching & Compression

Caching

Utilizing caching mechanisms is the simplest and fastest way to achieve results. For example, plugins like W3 Total Cache or WP Super Cache are super easy to install, and their purpose is to cache your WordPress website posts and pages as static files.

These static files get served to your users, which in turn reduces the processing load on the server. Caching can improve performance several hundred times over for reasonably static pages.

Compression

Websites load faster when the code they use is compressed, and the difference between loading time of compressed and uncompressed code can be as much as 300%.

Gzip compression works with almost all modern browsers, and you can enable it by using a WordPress plugin. Use of a plugin reduces the chances of an error when changing the code so you can consider using WPO Tweaks or W3 Total Cache plugins which can do this automatically.

If you want to enable this manually, please check the below examples.

Apache

Ensure that mod_filter module is loaded in Apache on your server, and paste following code to the websites .htaccess file:

<IfModule mod_deflate.c>

  # Compress HTML, CSS, JavaScript, Text, XML and fonts

  AddOutputFilterByType DEFLATE application/javascript

  AddOutputFilterByType DEFLATE application/rss+xml

  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject

  AddOutputFilterByType DEFLATE application/x-font

  AddOutputFilterByType DEFLATE application/x-font-opentype

  AddOutputFilterByType DEFLATE application/x-font-otf

  AddOutputFilterByType DEFLATE application/x-font-truetype

  AddOutputFilterByType DEFLATE application/x-font-ttf

  AddOutputFilterByType DEFLATE application/x-javascript

  AddOutputFilterByType DEFLATE application/xhtml+xml

  AddOutputFilterByType DEFLATE application/xml

  AddOutputFilterByType DEFLATE font/opentype

  AddOutputFilterByType DEFLATE font/otf

  AddOutputFilterByType DEFLATE font/ttf

  AddOutputFilterByType DEFLATE image/svg+xml

  AddOutputFilterByType DEFLATE image/x-icon

  AddOutputFilterByType DEFLATE text/css

  AddOutputFilterByType DEFLATE text/html

  AddOutputFilterByType DEFLATE text/javascript

  AddOutputFilterByType DEFLATE text/plain

  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)

  BrowserMatch ^Mozilla/4 gzip-only-text/html

  BrowserMatch ^Mozilla/4\.0[678] no-gzip

  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

  Header append Vary User-Agent

</IfModule>

NGINX

For NGINX, add the following code to your nginx.conf file:

gzip on;

gzip_disable "MSIE [1-6]\.(?!.*SV1)";

gzip_vary on;

gzip_types text/plain text/css text/javascript image/svg+xml image/x-icon application/javascript application/x-javascript;

Images

Non-optimized images are the most frequent cause of speed issues on a website. You should always use photo editing software to optimize your images before uploading them to your site.

There are two most common image formats used for web practices:

JPEG – Compressed file format which reduces both size and image quality

PNG – Uncompressed file format which has high quality but a larger file size.

A general rule of thumb on the usage of these is:

  • Use JPEG if the image has a lot of various colors
  • Use PNG if you need a transparent image
  • Avoid using irrelevant images on your site.
  • Make sure all images on your website are optimized. Plugins like Smush.it and WP Smush.it can help with this tremendously.

Make sure to resize large images and scale them properly utilizing this table:

  • Slider images: 1903(w) x 400(h)
  • Carousel images: 115(h)
  • Widget images: 414(w)
  • Fullwidth blog post images: 680(w)
  • Featured images: 250(w) x 250(h)

Fonts

If you’re utilizing Google Fonts, you may see errors in page speed tests related to cache validators. To fix this and improve performance, download the OMGF plugin, which allows you to host Google Fonts locally on your server, and save resources.

CDN

A Content Delivery Network delivers your website content to people more efficiently and swiftly based on the geographical location of the visitor. CDN consists of servers that are located in different regions around the world to improve content delivery for every geolocation.

From our experience – we recommend using Cloudflare as it’s one of the biggest CDN providers on the web and works well with WordPress.

Step 5. Advanced Optimization Tips

WordPress Database

If your website is up for a while now, your database probably contains a lot of information that is not needed anymore. You can clean that information by using a WP-Sweep plugin and improve the performance of your site. This plugin allows you to clean revisions, unused tags, deleted posts, etc.

WordPress Heartbeat

The WordPress Heartbeat API shows real-time plugin notifications. It also notifies you when another user is editing the same post as you. This can cause sluggishness and consumes quite a bit of server resources. We recommend using Heartbeat Control plugin to disable this behavior and save precious server resources.

External HTTP Requests

WordPress plugins and themes load tons of files from other websites/URLs, such as scripts, images, or stylesheets. Lots of these are optimized to load quickly, but if you have a ton of these requests, it could slow down your website quite a bit. To reduce the number of external HTTP requests, we recommend using a Merge + Minify + Refresh plugin, which will merge all CSS and scripts into groups and then minifies them for better performance.

Additionally, you can use this list of common domains to pre-fetch with the Pre* Party Resource Hints plugin to save on the load time.

Limit Posts Revisions

Some plugins don’t work well with WordPress Revisions, especially if you have a ton of them. If it doesn’t exclude revisions, each search through them can potentially slow down your website.

To limit the number of available revisions for each article, insert the following code to your wp-config.php file:

define( 'WP_POST_REVISIONS', 4 );

This particular code will limit WordPress to save only four revisions per each post or article and remove older ones automatically.

Pingbacks & Trackbacks

Pingbacks and Trackbacks are no longer used much for SEO, so you should disable them in Settings -> Discussion option:

Hotlinking

Having good content on your website will likely draw attention, and someone can “steal” it from you. This can be achieved by including your images directly from URLs on your server, and thus, you’ll end up paying for bandwidth instead.

To prevent this, add the following code to your website .htaccess file:

#prevent hotlinking

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?skystra.com [NC]

RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]

RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L] 

NOTE: Make sure to replace skystra.com URL with your domain name.

Long Posts

If you have a lot of long posts – this is great for search engines, but it affects loading times on your website. Consider splitting long posts into pages to prevent this from happening. Since WordPress has this functionality built-in, you can use the following tag in your article where you want to split it into the next page:

<!––nextpage––>

Lazy Loading

If you utilize a lot of videos, images, galleries, etc. on your website – you could profit from lazy loading. Lazy loading will only display content on the viewers’ screen instead of loading all the assets at once and thus improve the loading time of the page.

We recommend Lazy Load by WP Rocket plugin, which you can use to lazy load images, iframes, videos, and so on.

SSL

If you moved your website to utilize SSL certificate – ensure that you don’t have any mixed content errors (where you have both HTTP:// and HTTPS:// URLs in your database).

To fix this, we recommend using Better Search Replace plugin to update all URLs in your database to use the new HTTPS URL.

Bad Bots

Using the Block Bad Queries plugin can help you automatically block bad known bots, and thus quickly reduce CPU load from bad bots.

Additionally, go to Google Search Console and in Site Settings reduce the crawl rate to limit the amount of Google requests to your website. You can also do this for Bing via crawl control settings option.


That’s it! Feel free to contact us if you have any further tips you’d like us to include in this guide, or if you need any additional assistance.

2 Comments on “How to Optimize WordPress for Better Performance”

  1. JBO VND says:

    Hi, i think that i saw you visited my weblog so i came to go back the prefer?.I am attempting to find things to improve my web site!I guess
    its adequate to make use of some of your ideas!!

  2. JBO VND says:

    I every time spent my half an hour to read this website’s posts every day along with a cup of coffee.

Leave a Reply

Your email address will not be published.