How to Optimize Your WordPress Site’s Performance
This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible.
You don’t want a slow website. Potential visitors may leave before your page even finishes loading. And you’ll be penalized in search results, meaning even less traffic.
You want your web pages to load in two seconds or less. How do you achieve that? One step at a time.
In this article we cover a list of items you can optimize to speed up your WordPress site. In our next article, we’ll give you a list of plugins that will help.
Just How Slow Is My Site?
Your site may not feel slow to you. Most likely your browser has already cached it, so you won’t be experiencing it the same way as a new visitor.
Here are some services that will inform you how long your page takes to load and tell you the overall file size of your page:
Check the speed of your sites before and after tweaking your site for performance. If you can get your pages loading in two seconds, you’re doing well.
Keep a record of how much difference each step you take makes. What made the most difference?
1. Choose a Good Web Host
It’s impossible to speed up a website that’s being hosted on a slow server. Choosing the right hosting provider is the first important step towards having a fast-loading website.
How do you choose a company that makes speed a priority? Check out our Performance Checklist in The Ultimate Guide to Choosing a Hosting Provider.
SitePoint recently partnered with SiteGround as our official recommended host. With servers on multiple continents and the use of the latest SSD hardware, an in-house caching tool, and a free CDN service, SiteGround provides and invests heavily in speed acceleration. Their flexible servers support PHP7 and HTTP/2 and they have ongoing software and hardware updates.
2. Optimize Your Theme
First, use a fast theme. Themes with a lot of options make your job easier, but at the expense of making the web server and browser work harder. Some WordPress themes are megabytes in size, adding seconds to your page loading time.
Every feature you don’t use slows your site down for no reason. If you’re comfortable tweaking code, choose a theme with fewer options to speed up your site.
- The default WordPress themes are easy to tweak, lightweight, and well-coded. Consider using one and either tweaking the code yourself, or hiring a developer.
- Thesis and Schema are two more themes that prioritize performance.
- Finally, SitePoint’s own WordPress Base Theme is another excellent starter theme. It’s light-weight and fast, hitting 98/100 on the Pingdom Page Speed Test.
- What is the Best WordPress Theme?
- 9 of the Most Popular Free WordPress Themes
- How to Design a Complete WordPress Website With Base Theme & Elementor
Second, use a responsive design. These load less resources for mobile devices, or specify high-res images for desktop displays. Mobile users don’t have to download huge images, while desktop users don’t have to squint at tiny ones.
Responsive sites are also preferred by Google, so expect a slight boost in SEO once you switch.
3. Monitor Your Plugins
First, minimize the number of plugins you use. Before you install any plugin, ask if it’s really necessary. Having a large number of plugins installed won’t make a huge difference to the speed of your site, but it increases the risk of installing badly behaved plugins.
Second, make sure your plugins are optimized for the current version of WordPress. Perform some research before installing a plugin, especially if it is rated three stars or less. It may be poorly developed, or use inappropriate hooks. This will slow down your site, and may also adversely affect WordPress and your other plugins. It’s also important to keep plugins updated to ensure you have the latest performance improvements, security patches, and features.
4. Optimize Your Widgets
If a widget is unlikely to be updated often, upload it directly to your server. By not having to rely on external servers, you’ll improve your site’s loading time.
5. Optimize Your Static Content
First, compress static content with gZip. Compressed files are smaller, so will obviously load faster.
- The best option is to enable gZip compression straight from cPanel (if your host offers you that) if you’re on a shared server.
- You can enable gZip compression using a plugin like W3 Total Cache. We’ll cover plugins in our next article.
Second, take the load off your web server with a CDN. Your static resources (like images, scripts and CSS files) will be served from optimized Content Delivery Network servers all over the world—generally the closest server to your visitor. And your web server will be freed up to serve the rest of your site, improving performance.
Ideally, look for a web host that offers a CDN in its hosting plans, like SiteGround. There are also lots of CDN networks out there:
These work with the caching plugins we’ll cover next time.
Here’s some further reading about CloudFront:
6. Optimize Your Images
Images are one of the heavier elements of your site – they make up over 65% of web content. There are a few ways you can optimize your uploaded images.
First, specify maximum image dimensions for thumbnail, medium, and large sized images. You’ll find these options in Settings/Media. If you upload a 1024px image and your content area is only 604px wide, the image will be scaled down using CSS. The resulting pre-resized, 604px wide image will be significantly smaller to download.
Second, smush it! This technique reduces image file sizes losslessly, without resizing them or downgrading their quality. While Yahoo killed the Smush.it service a few years ago, there are alternatives like reSmush.it, and a number of plugins which we’ll cover in the next article.
Third, employ lazy loading. This technique is effective for image-heavy sites. Images are only loaded when they become visible, not when the page is initially loaded. This can speed up page load times dramatically, though there will be a delay when displaying images when they scroll into view.
Fourth, choose the best image format for your website. Some image formats are easier to work with, while others are smaller. For example, scalable SVGs have smaller file sizes, especially if you optimize them for the web and compress them with gZip.
Learn the pros and cons of a variety of image formats here:
- What Is the Right Image Format for Your Website?
- Is Using SVG Images Good for Your Website’s Performance?
Fifth, use CSS sprites. Performance is improved by combining lots of small theme and miscellaneous images into as few images as possible. Learn more here:
Finally, check out this comprehensive overview of optimizing images:
7. Optimize Your Database
WordPress pages load from a mySQL database. Over time, the database may contain a lot of information you no longer need. Optimizing your database removes this information and improves performance.
You can optimize your database directly from phpMyAdmin. You can also optimize it with plugins. We’ll cover these in our next article.
8. Speed High-Traffic Sites with Caching
Caching is very effective at optimizing high-traffic sites. Every time a WordPress page is loaded, information is retrieved from your database and CSS files, and is combined into a HTML file which can be loaded into the visitor’s browser. This takes time.
Caching keeps those HTML files available for future visitors, saving significant time. We’ll cover caching plugins in our next article.
9. Perform Routine WordPress Maintenance
Keep your WordPress site in tip-top shape by regularly maintaining it. Some maintenance routines can significantly speed things up, in particular:
- Keep WordPress and your plugins up to date.
- Delete old post revisions.
- Delete spam comments.
Learn how to do these and much more here:
10. Use Performance Plugins
For many optimization tasks, there are WordPress plugins that will take care of the heavy lifting for you. We’ve covered eight of the best plugins that cover all the bases. We’ve also listed almost two dozen alternatives so you can explore which best suit your needs. Dive in and see what makes the most difference to your site.
If you’re following our WordPress Maintenance Checklist you’ll probably already be using some of these plugins. Keep it up! That cruft will continue to accumulate.
Have we missed your favorite plugin? How has it helped? Let us know in the comments.
- Cost: free
- Active installs: 1+ million
W3 Total Cache can also work with your CDN (like Cloudflare or MaxCDN) to further improve load times.
W3 Total Cache improves the SEO and user experience of your site by increasing website performance, reducing download times via features like content delivery network (CDN) integration.
If you prefer to avoid using plugins, a good option for you would be to look for a hosting provider that will do the caching for you. Our partner SiteGround has a great caching tool, developed in-house, that can help you drastically boost your website speed.
- Cost: free
- Active installs: 600,000+
This free plugin will optimize your WordPress database with the click of a button, or automatically with its built-in scheduler. Redundant information like spam comments, post revisions and other trash items will be cleaned from your mySQL database, speeding up how quickly your site loads.
WP-Optimize is an effective tool for automatically cleaning your WordPress database so that it runs at maximum efficiency.
- Cost: free
- Active installs: 300,000+
Poorly structured CSS and HTML will result in a slow site and lost traffic. This plugin scans and tweaks your site, “minifying” and removing redundant code.
To prevent compatibility conflicts, Autoptimize can ignore your other plugins. It can also force your plugins to run in a specific order. By experimenting with this, you might be able to drastically improve your loading times.
Autoptimize makes optimizing your site really easy. It concatenates all scripts and styles, minifies and compresses them, adds expires headers, caches them, and moves styles to the page head and can move scripts to the footer.
- Cost: free
- Active installs: 100,000+
Bad plugins can adversely affect the performance of your site. P3 will evaluate yours. It will identify the plugins that have the biggest impact on your site’s load time, and display them in a pie chart so you can easily see which tweaks will make the most difference.
This plugin creates a profile of your WordPress site’s plugins’ performance by measuring their impact on your site’s load time. Often times, WordPress sites load slowly because of poorly configured plugins or because there are so many of them. By using the P3 plugin, you can narrow down anything causing slowness on your site.
Alternative plugin-related plugins include Plugin Organizer.
5. WP Smush
This plugin compresses images by stripping metadata from JPEG files, optimizing JPEG compression, converting certain GIFs to indexed PNGs and stripping the unused colors from indexed images. You can set it up to automatically compress new images when they’re uploaded to your site.
WP Smush is fast, and performs well. Files are compressed using dedicated servers, and it’s recommended by the site performance tool GTmetrix.com.
Resize, optimize and compress all of your images with the, incredibly powerful and 100% free WordPress image smusher, brought to you by the superteam at WPMU DEV!
6. Lazy Load
- Cost: free
- Active installs: 90,000+
This plugin makes sure images are loaded only when they are visible above fold. It doesn’t require configuration and works out of the box.
Lazy load images to improve page load times. Uses jQuery.sonar to only load an image when it’s visible in the viewport.
- Cost: free
- Active installs: 100,000+
Rather than offering lossless compression, this free plugin automatically resizes images to a more “sane” resolution. It’s able to set a maximum width, height and quality of images, and can convert BMP files to JPG.
Imsanity automatically resizes huge image uploads down to a size that is more reasonable for display in browser, yet still more than large enough for typical website use. The plugin is configurable with a max width, height and quality.
- Cost: free
- Active installs: 5,000+
This plugin compresses your pages in the gZip format (if the browser supports compressed pages). HTTP compression can reduce the size of your pages by 60-80%, allowing pages to load three or four times faster.
This plugin allows your WordPress blog to output pages compressed in gzip format if a browser supports compression.
You can also enable gZip compression from W3 Total Cache mentioned above, or in the settings of your web host’s control panel.
11. Further Tips
- Empty your trash. There can be a lot of trash in your database that will slow your site’s performance. By default, WordPress automatically deletes trash after thirty days. You can empty the trash manually from your dashboard, and we’ll share some helpful plugins in our next article.
- Turn off trackbacks and pingbacks. These use server and database resources every time someone mentions your site. Turning the setting off (from WordPress’ Discussion settings) won’t destroy the backlinks, just the work that is generated.
Have a Go!
How slow is your site? Use one of the tools listed above to find out. Then try one or more strategies and test your speed again. Then repeat.
SiteGround, our preferred hosting provider, allows you to use powerful performance optimization techniques with just a few clicks. Their guide to improving WordPress performance includes full tutorials on many of the topics we’ve covered in this article, including caching, gZip compression, using a CDN, optimizing images, and optimizing the WordPress database.
Which optimization strategy made the most difference on your website? Let us know in the comments.