Reduce Misc HTTP Requests


8.8

Decreasing the amount of HTTP requests that WordPress makes is very important. Follow these instructions on how to fix the gravatar problem and the additional request to load emoji’s since WordPress 4.2

Gravatars

If you are using the native WordPress commenting system by default it creates a separate HTTP request for each gravatar. If you have a lot of comments this can result in tons of requests and unnecessary redirects as seen in the example below.

There are a couple options you have to get around this.

Option 1 – Disable User Gravatars

The first option is to simply disable user gravatars and use only local avatars. This is not ideal, but how important is WordPress speed to you?

To do this install the free WordPress plugin WP User Avatar. This In the settings menu click on “Disable Gravatar and use only local avatars.” Then choose a default avatar.

Option 2 – Disqus is Faster

Your second option is to lazy load Disqus as we mentioned earlier. Yes, this seems strange because adding a javascript file, plugin, and an external call normally would mean additional load time. But if you compare this to a blog posts with 5 or more comments than Disqus is actually faster because of the reduced number of HTTP requests.

Disable Emojis

With the release of WordPress 4.2 came updates for additional emoji support. Unfortunately what this means is that they are now including an additional javascript file wp-emoji-release.min.js?ver=4.3.1 in your header. This creates an unnecessary additional HTTP request, especially if you don’t want to even use them.

Follow the instructions below to disable emoji’s and get rid of that additional HTTP request.

First under “Writing Settings” in WordPress make sure you uncheck the “convert emoticons” option under formatting. Then follow the rest of the steps below.

Option 1 – WordPress Plugin

Install the free WordPress plugin “Disable Emojis” by Ryan Hellyer. This plugin disables the new emoji functionality in WordPress 4.2.

Option 2 – WordPress Function

If you don’t want the overhead of another plugin then simply take the code from Ryan’s plugin and drop it into the bottom of your functions.php file.

Disable Scripts on a Page-level Basis

Normally you want to get rid of plugins, but there is a plugin called Gonzalez which actually lets you disable unnecessary scripts from loading on a page-level and site wide basis. It isn’t free, but well for the money if you are trying to squeeze out a little more speed. For example, Contact Form 7 is a great form plugin for WordPress, but by default it loads its script on every single page. With this plugin you can easily disable it and only load it on your contact page. Then repeat with your social sharing plugin, etc. You will most likely be able to get rid of at least 5 or more HTTP requests/scripts by using this plugin.

Disable Embeds

Since WordPress 4.4, there is a new script that is loaded, wp-embed.min.js which allows you to more easily embed videos, images, tweets, etc. For example, WordPress will automatically turn the URL into a YouTube embed and provide a live preview in the visual editor. A lot of people don’t use this feature or might not need it. You can always link the original way by grabbing the embed code off of YouTube or Twitter. The big issue with this feature is that is loads the script on every page. There are a couple ways to disable this script.

Option 1 – WordPress Plugin

Install the free WordPress plugin “Disable Embeds” by Pascal Birchler. This plugin does the following:

  • Prevents others from embedding your site.
  • Prevents you from embedding other non-whitelisted sites.
  • Disables all JavaScript related to the feature.

Option 2 – WordPress Function

Or you can drop the following into the bottom of your functions.php file to also disable embeds

Disable Comments

Whenever you are using threaded comments in WordPress the comment-reply.min.js script is included on every post and page. There might be times when you don’t need this script. Maybe you don’t allow comments on your site or you use a 3rd party commenting system like Disqus. In those cases there is no need for this script to load on every page.

To disable this script you can drop the following code into the bottom of your functions.php file.

About the Author: admin

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *

Start an internet business today!