Quick tips to optimize WordPress site load time

QUICK TIPS TO OPTIMIZE WORDPRESS SITE LOAD TIME

1 Comment

You know the feeling. You’ve clicked on an interesting link to visit a site, and you’re patiently waiting for it to load. And waiting. And waiting. Your patience is wearing thin, and suddenly the link-that-looked-interesting has become the site-that-will-never-load. In frustration, you slam the X to close the window and huff off to another site.

In reality, the wait time might only have been three seconds, but in Website Time, it feels like an eternity. Our fast-paced, on-demand society demands information be available in the blink of an eye. In fact, survey information indicates nearly half of Internet users (47 percent) expect a page to load in two seconds or less. Even shaving a half-second off your site’s load time can make a huge impact on your bottom line.

While there are a plethora of factors that can impact a site’s loading time, there are a few basic and relatively simple things you can do to decrease the wait.

START AT THE SERVER: HTACCESS IS YOUR FRIEND

Server-side caching can make a big impact. Before your user ever even requests your site, you can have settings in place to make that request load faster. These changes involve editing your site’s .htaccess file, which should be in the root folder of your website. You’ll need FTP/SSH/cpanel access to edit this file.

Pro tip: One wrong move in the .htaccess file can make your website inaccessible — so try these changes during off-hours, and make sure you have a backup of the .htaccess file to restore if that happens.

BROWSER CACHING: SET YOUR EXPIRATION DATES

Some types of content change frequently. Others, like images, will remain the same whether they’re requested today or in a week (that picture of a cat is still going to be a cat five days from now). Setting longer expiration dates for more static content can decrease load time on your site, since the browser knows it doesn’t have to request a new copy every single time. To specify longer expiration periods for more static content, add the following to your .htaccess file:

As you can tell from the code lines, we’re setting content such as images (.jpg, .gif, .png file extensions) to have the longest expiration “dates.” Other content types that probably don’t change as often (but do change more frequently than images) are set to cache for one month. The default for any type not specifically defined is set at two days.

EXCEPTIONS TO THE CACHING RULE

Sometimes, however, you don’t want to serve cached content. Certain websites (Google, for instance) should always pull the newest information from your site, rather than old, potentially stale cached data. These exceptions can also be handled within your .htaccess file. Within your WordPress rewrite rules, add the following:

…your wordpress stuff here, then add…

This command tells the browser NOT to cache information for Google, but to have the search engine retrieve it again fresh each time. You can, of course, add additional rewrite conditions for other URLs if you have more sites you want not to receive cached content.

UTILIZE GZIP COMPRESSION

It’s common sense in the tech world: smaller files will always transfer faster than larger files. Another way to reduce your site’s load time is to serve smaller files to the browser. This is easy if you activate gzip compression. Gzip automatically compresses your stylesheets and site’s pages before serving them to the browser making the request. Compression = smaller file sizes, which = shorter transfer times. Using this one tool can drastically improve your site’s load time. To utilize gzip compression, add this code to your .htaccess file:

GO BEYOND THE SERVER: OPTIMIZE YOUR CONTENT

Beyond adding commands to the .htaccess file to deal with your content as it’s delivered, you can also do things to optimize the content itself. Let’s face it, if your content is sloppy or ill-conceived, no amount of caching or compression is going to save your load speeds. Fortunately, there are a few easy techniques for optimizing your content that can make a big difference.

Say goodbye to oversized images

One of the biggest culprits of slow loading time in WordPress is image size. When you upload an image via the standard WordPress Media Library, you upload the full-sized image. WordPress will simply scale down that image to smaller sizes; the overall file size of that particular image remains the same.

The most obvious way to avoid this problem is to resize images before upload. If you don’t want to take the time to resize every image by hand, though, you can spice up the vanilla WordPress media uploader with the use of a plugin like Imsanity. Install, activate, and all images uploaded are automatically resized into smaller, more manageable files before they’re ever added to your server.

Compress images even more

Another handy tool to reduce image size is an image optimizer, which takes the image file and removes any unnecessary data bytes stored within. This is a lossless technique, meaning you end up with a smaller image without any loss of image quality. And again, there are plugins to handle this for you. Check out the EWWW Image Optimizer or WP Smush.it.

Tell ‘em what to expect

Remember when I told you to specify image dimensions in your posts? Search engines prefer images with specified sizes. Well, here’s another good reason to make that standard practice: it can also help improve your load times. If the height and width of an image already is specified in the code, the browser doesn’t have to take the time to interpolate every image.

CHECK YOUR WORK

There are, of course, many other ways to tweak your website and deliver the fastest possible site to your users. If you want to check the overall load time of your site or see other ideas of how to improve, here are a few of my go-to tools:

Do you have other must-know tips or tricks to reduce site load times or improve speed? Please share your brilliance in the comments!