in Web Development, Wordpress

Optimising WordPress for PageSpeed Insights

Recently I was commissioned to optimise a WordPress site on behalf of an SEO agency. This usually consists of reports from Google’s pagespeed insights and there’s a number of things you can do to increase the speed.

pagespeed

Before you start you should first check that the foundations are correct.

Enqueue

For example all JS and CSS files are properly enqueued in WordPress we will later need to work on minifying and combining these into one file.

HTML Structure

Ensure important page elements are near the top, move your html around if required and ensure that your CSS files are ordered in the way the page loads you might want to break the css up into two files. The first loading important structure e.g header, body content etc.. The second appearing in the footer loading the remaining part of the site.

Onto the optimisation

Optimise images

The next thing you want to look at is image optimisation there’s a plugin you can install that optimises all image uploads as you upload them which in turn utilises some command line tools to compress images e.g optipng and jpegoptim. You also need to run these tools on the existing image library.

Set an expiry on assets through nginx or apache or alternatively just use Cloudflare or any CDN of your choice.

Minify HTML

HTML Minify https://github.com/cferdinandi/html-minify does a decent job of minimising your html.

Minify CSS/JS

You then need to install a plugin to combine your css/js and again work on the order here to ensure the right delivery.

Blocking

Fonts are often blocking resources, consider using Google’s Font API instead and anything else that isn’t critical either defer or move to the bottom of the page.

A lot of the above can also be achieved in part of in full by Google’s pagespeed module you’ll achieve better results though by doing each part onsite.

Image resizing

If you have any scripts that work with images e.g sizing images on the fly or creating thumbnails and have a very large amount of images either through the creation of different sizes or in total watch out for anything that reads the folder they are contained in as this can put a serious performance hit on your server.

Write a Comment

Comment