How to speed up a WordPress website 2019

Your WordPress website is too slow? Here is an action plan for increasing the PageSpeed rate. No need to involve developers!

1. Remove unnecessary scripts

No matter whether you create a new theme on scratch or use this post for optimizing an existing one, I’d recommend to review the following scripts and update those used at your website:

Emoji support
By default, Emoji are enabled after WordPress installation. If you don’t need Emoji in your posts and comments, you may remove the script and the style sheet which fetch them. Just add the following strings into functions.php file:

remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );

Comments
If you don’t use an integrated post commenting system or if you use another platform (e.g., DISQUS), you may remove the unnecessary comment script. Please add the following code into functions.php:

function remove_comment_reply_script () {
wp_deregister_script ('comment-reply');
}
add_action ('init', 'remove_comment_reply_script');


oEmbed
In WordPress 4.4 versions and higher oEmbed is available by default. It allows embedding such media as tweets or YouTube videos and these are additional scripts. If you don’t need oEmbed, you may remove it by installing this plugin or adding the following function into functions.php:

function speed_stop_loading_wp_embed () {
if (! is_admin ()) {
wp_deregister_script ('wp-embed');
}
}
add_action ('init', 'speed_stop_loading_wp_embed');


New Gutenberg editor
If you have updated WordPress to version 5.0, but prefer Classic Editor, WordPress still adds the Gutenberg editor script on your website. For removing this script add the following into functions.php:

function remove_block_library () {

wp_dequeue_style ('wp-block-library');

}

add_action ('wp_enqueue_scripts', 'remove_block_library', 11);


Contact Form 7
If you use Contact Form 7, you might have noticed that the plugin enables JavaScript and CSS on pages which don’t have any contact forms.
Add the snippet below to the function file for enabling it on the contacts page only and change $pages array for enabling page slugs which contain contact forms:

function cf7_scripts() {

add_filter('wpcf7_load_js', '__return_false');

add_filter('wpcf7_load_css', '__return_false');

$pages = array('contact','home');

if (is_page($pages)) {

if (function_exists('wpcf7_enqueue_scripts')) {

wpcf7_enqueue_scripts();

}

if (function_exists('wpcf7_enqueue_styles')){

wpcf7_enqueue_styles();

}

}

}

add_action('wp_enqueue_scripts', 'cf7_scripts', 20);

function remove_comment_reply_script () {

wp_deregister_script ('comment-reply');

}

add_action ('init', 'remove_comment_reply_script');


oEmbed
In WordPress 4.4 versions and higher oEmbed is available by default. It allows embedding such media as tweets or YouTube videos and these are additional scripts. If you don’t need oEmbed, you may remove it by installing this plugin or adding the following function into functions.php:

function speed_stop_loading_wp_embed () {

if (! is_admin ()) {

wp_deregister_script ('wp-embed');

}

}

add_action ('init', 'speed_stop_loading_wp_embed');


New Gutenberg editor
If you have updated WordPress to version 5.0, but prefer Classic Editor, WordPress still adds the Gutenberg editor script on your website. For removing this script add the following into functions.php:

function remove_block_library () {

wp_dequeue_style ('wp-block-library');

}

add_action ('wp_enqueue_scripts', 'remove_block_library', 11);


Contact Form 7
If you use Contact Form 7, you might have noticed that the plugin enables JavaScript and CSS on pages which don’t have any contact forms.
Add the snippet below to the function file for enabling it on the contacts page only and change $pages array for enabling page slugs which contain contact forms:


function cf7_scripts() {

add_filter('wpcf7_load_js', '__return_false');

add_filter('wpcf7_load_css', '__return_false');

$pages = array('contact','home');

if (is_page($pages)) {

if (function_exists('wpcf7_enqueue_scripts')) {

wpcf7_enqueue_scripts();

}

if (function_exists('wpcf7_enqueue_styles')) {

wpcf7_enqueue_styles();

}

}

}

add_action('wp_enqueue_scripts', 'cf7_scripts', 20);

2. Remove unused plugins

Any unused plugins may increase the load time or Time to First Byte. The plugin may run its logic at every request or enable JavaScript, style sheets, fonts or other resources which increase the general size of the page intended for downloading by your users.

3. Keep WordPress and plugins updated

Update your plugins and WordPress core on a regular basis. Such updates may include fixes of performance issues which improve the overall website efficiency.

4. Limit revision publishing

Below you can find the revisions of my previous post on Ahrefs:

Ahrefs

By default, WordPress stores an unlimited number of revisions which add up and may bloat the database. This increases the time required for requests to the database. You may limit the post revision number by adding the following string into file wp-config:

define( ‘WP_POST_REVISIONS’, 3 );

Insert the code over “ABSPATH”, otherwise it wouldn’t work.

5. Use optimization plugins

WP Smush

In line with non-optimized images plugins often lead to poor performance. However, there are two plugins which I’d recommend to install first of all for supporting the website and increasing its performance.

This plugin crops, compresses and optimizes all images uploaded into the media library.

Autoptimize

Speed up your WordPress website with Autoptimize

Autoptimize with minimal settings combines, compresses and reduces all your scripts and styles. It can even reduce the HTML code leaving out all unneeded bytes and increasing the desired PageSpeed score.

WebP Express

How To Serve Images In Next-Gen Formats Using WordPress

WebP is a new format of image files by Google. It is compatible with the latest Chrome, Firefox and Edge versions. WebP images usually have a smaller size than similar files in JPG or PNG format so it’s recommended to use WebP images with compatible browsers.

WebP Express plugin automates this by converting your images into WebP (if needed) and sending source JPG or PNG files to the browsers which are not compatible with WebP.

6. CloudFlare

CloudFlare uses a wide range of tools which speed up your website.

If you still don’t use CloudFlare, here’s how you can configure it.

Autominify in Speed tab will reduce the HTML, CSS and JavaScript size. Brolti will also spare some bytes by compressing the resources. Rocket Loader will reorganize your JavaScript so that the initial resources will be first to load (e.g., CSS). Please make sure that your website is working after the setup))

You can try out all its benefits on your website.

7. Use a good hosting

It is very important to choose a proper hosting.

In some cases, recommended to change the hosting, sometimes it can drastically change the load performance of a WordPress website.


Some examples our work:

As a result you can get the following: https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fdevfuture.pro&tab=desktop