How To Improve Wordpress Speed and Performance
How To Improve Wordpress Speed and Performance
It’s easy to feel frustrated at this point in the project, but don’t fret. Before you knock down the
door of your web host or add a ton of sketchy plugins, follow these easy steps to make your
WordPress site smooth, solid, and super speedy.
While the price tag of shared hosting makes it seem like a bargain, it comes at a different cost:
the risk of slow site speed, irregular performance, and frequent downtime. All things that affect
the reliability and speed of your site. The stress isn’t worth it, especially when you have the
ability to choose a managed WordPress host (like Flywheel!) that’ll take care of a huge chunk of
your performance woes.
With Flywheel’s managed hosting WordPress platform, you’ll get top performance out of even
the highest traffic websites. Robust caching comes standard on every site, and you can always
add a CDN to watch your site fly. Plus there’s always our top-notch support team, beautiful
dashboard, and a whole plethora of features to help you build blazing fast WordPress sites.
What is Flywheel?
Flywheel is a delightful platform that empowers designers, developers, and digital agencies to
focus on what they do best — building beautiful, functional sites for their clients. We make it a
breeze to create and develop WordPress sites, handle hosting, manage projects, and ultimately
scale your business.
Stop wasting time on server management, security plugins, caching, and all those other boring
repetitive tasks that take your focus away from growing your business and jeopardize your
relationship with clients. Get Flywheel and get back to doing what you love.
LEARN MORE
You can track down which plugins might be causing performance losses on your site quite
easily. We generally use a plugin called Query Monitor that sifts through your whole site and
reports back what percentage of total load time each plugin is responsible for using. If you’re
serious about speed, you’ll run a test each time you activate a new plugin, to ensure you’re not
installing something that will sacrifice speed. Plus, by benchmarking your plugins right off the
bat, you won’t waste time messing with a plugin if it’s not going to perform well in the long run.
If there are plugins that you just can’t live without but still make your site slow, there are ways
to continue using them. Generally, if you determine that a plugin is loading slowly, the next
step is to talk to your hosting company to increase the memory on your server. With Flywheel,
that generally means upgrading your plan to the next level to get more memory and, thus,
more speed. Eliminating the need to do this is the best plan of action, but there probably are a
handful of plugins that you might find yourself not willing to ditch (WooCommerce, for
example).
Similarly, on the server side, having a caching layer works wonders for serving your site up very
quickly. The most common way to enable server-side caching with WordPress is by using the
W3 Total Cache plugin. This plugin (or one similar) is needed on almost all hosts.
The exception to this rule is Flywheel; we handle server-side caching for you behind the scenes
with Varnish. Using Varnish instead of a plugin can increase speeds dramatically because
Varnish never has to talk to PHP. It serves up cached static copies of your site immediately
(without even touching the PHP application layer), whereas plugins are still run by PHP. On
managed hosts like Flywheel, the server-side caching tells the browser how long to cache
things by setting “expires headers.” The browser won’t ask the server for more information if
those headers tell it not to ask.
WooCommerce, for example, disables server-side caching by setting cookies. It’s typically not
very apparent when plugins or themes disable caching, so a good thing to do is reach out to
your hosting provider and ask that they force cache your site. Be careful not to force caching
on pages that truly need cookies to work, though, such as WooCommerce cart and checkout
pages.
For example, let’s say you’re not using a CDN and your site is hosted in San Francisco. When
someone from, say, Barcelona visits your site, they have to retrieve all your assets from your
server in San Francisco. The long distance between the two locations clearly takes longer than
if someone from San Francisco loads your site that’s hosted in San Francisco. A CDN, on the
other hand, serves your assets from a bunch of different servers based around the world, such
as New York, Seattle, Omaha, Paris, London, Beijing, AND San Francisco (and many more).
The idea is that users will hit the server closest to them and not sacrifice load time, since there’s
a smaller distance between them and the server. With a CDN, that same person from Barcelona
will now hit a datacenter in London or Paris, instead of San Francisco. Using a CDN will
definitely increase the speed of your site for users throughout the world!
Some of the most popular CDNs include Amazon Web Services, CloudFlare, and MaxCDN.
Most of them have free plans, but if you pull a lot of visitors and have lots of assets, you’ll most
likely have to pay for it. They’re typically pretty easy to set up, but if you want a super slick
solution, be sure to check out Flywheel’s MaxCDN add-on.
Images are often the biggest files on a page, responsible for the largest delay in page load time.
The good thing about images, however, is that unlike CSS and JavaScript, most browsers load
them asynchronously. That at least helps with the perceived performance of a page, but you
still want to make sure that:
Compression tools are necessary for squeezing out as much excess as possible on images.
ImageOptim is a great Mac app that does this well, along with OptiPNG and jpegtran for use
with task runners like Grunt. TinyPNG is our go-to web-based compression tool. It can become
cumbersome doing this with every image, though, and sometimes not even feasible if multiple
people are contributing content. Thankfully, there are some WordPress specific tools available
to help with this.
When you have multiple sizes of images that are cropped upon upload (usually defined in most
themes), using an image compression WordPress plugin is particularly important. Even if the
initial image that you uploaded is as trimmed and compressed as possible, when WordPress
generates the new images from that, those new sizes won’t be compressed.
We have used and recommend TinyPNG for WordPress and Ewww Cloud Optimizer to handle
the compression and optimization of images uploaded to WordPress.
CSS
The most important thing to do with your CSS before it’s delivered to the browser is simply to
compress it and remove unused selectors. Getting a good development workflow down when
developing themes makes this process trivial, especially if you’re using a pre-processor like
Sass. We’d recommend Grunt, which is a JavaScript task runner that executes commands for
you while developing. There’s a plugin for Grunt called grunt-contrib-sass that simply compiles
all your Sass files down into one, minifies it, and compresses it. Throw in the
grunt-contrib-watch plugin on top of that, and it will run the Sass task whenever you save a file.
Don’t lose sleep if you’re not using the latest and greatest CSS methodology, but try to follow
some sort of standard while authoring CSS to avoid duplication and huge file sizes.
The golden rules of optimizing JavaScript are simple: Serve as few JavaScript files as
possible, minify, and concatenate. Third-party WordPress plugins can be detrimental by
bloating your document with unminified blocking JavaScript files, so it’s important to be
mindful when choosing plugins. Ideally, you’d concatenate ALL JavaScript files into one and
then minify the heck out of it. For times when it’s not possible to concatenate all your les into
one, there are HTML attributes called “async” and “defer” that can be used to load JavaScript
files asynchronously or once the rest of the page is loaded.
One tool that has saved us from a logic intensive loop taking forever to load is the Transients
API. WordPress transients store cached data in the database temporarily, which means your
logic only has to run once (whenever the first visitor loads the page) and then the results of that
are stored in the database. The Codex has good documentation on the usage of transients, as
well as a host of other articles found with a Google search.
CSS
Once your stylesheet is compressed and ready to go, the easiest (and by far, the standard) way
to load it is to just reference it in the <head>. That way, the browser loads and parses it before
the rest of the DOM is loaded.
<head>
</head>
However, there’s a fairly new technique where “critical” styles are inlined in the <head> and
then the full stylesheet is loaded asynchronously using JavaScript. Critical styles are defined as
those that are needed to paint everything that the user first sees (“above the fold”) when they
initially load your page. The best way to grab critical styles from a page is by using Grunt (or
another task runner) paired with a task like grunt-critical or grunt-criticalcss. The Penthouse
web generator is also a solid way of extracting critical styles.
Once you have the critical CSS ready, it’s as simple as inserting it into a <style> tag in the head.
<head>
*/<style>
JAVASCRIPT
The most common place nowadays to reference JavaScript is at the bottom of your document,
right before the closing tag. However, there are more advanced techniques to load JavaScript.
Again, the Filament Group has done tons of research on this and has several open source
projects that you can use if you’re aiming for a super fast page load time (we’re in no way
affiliated with Filament Group, by the way; we just think their stuff is awesome). The best
approach seems to be to load scripts dynamically by inlining a small function in the <head>;
that then appends script tags without blocking the rest of the page.
After you’ve gone through these performance-enhancing practices, if your site is still really
slow, we’d recommend hiring a developer who can look into it and find the source of the
problem and/or choosing a new WordPress host.
See how Flywheel can help boost your site speed and overall
workflow today!
CONTACT SALES
[email protected] | 402-223-6105