How to Analyze and Reduce HTTP Requests on WordPress

How to Analyze and Reduce HTTP Requests on WordPress

how-to-analyze-and-reduce-http-requests-on-wordpress

Looking to reduce the HTTP requests on your WordPress website? When you’re trying to speed up your WordPress site, there are some simple non-technical solutions that make a great starting point, like choosing a quality WordPress host and using a WordPress caching plugin.

WP Rocket - WordPress Caching Pluginmy simple WordPress portfolio site only needs 18 requests, while the New York Times website has 231 requests, in large part because of a huge number of tracking scripts.

Why Do HTTP Requests Matter for WordPress Sites?

You can probably see where this is going…

In general, if a browser needs to make more HTTP requests, it’s going to take longer to load the page because it needs to request a lot more information. If you can remove some of those requests, there’s less to load, which means your site loads faster.

A basic rule of thumb is that “fewer HTTP requests = a faster-loading WordPress site“.

Of course, it’s not quite that simple because not all HTTP requests are created equal. Requesting a tiny tracking file might only take a tiny fraction of a second, while requesting a huge unoptimized image could take half a second.

So if you want the more specific version, it’s something like…

  • Eliminate unnecessary HTTP requests to have as few requests as possible
  • Pay special attention to slow HTTP requests as they have a larger impact

How to Analyze HTTP Requests in WordPress

The best way to analyze your site’s HTTP requests is with something called a waterfall analysis. This analysis shows you:

  • How many overall requests your site has
  • Each individual request
  • How large each request is
  • How long each request took

Most performance testing tools can help you perform a waterfall analysis, including:

I’m going to use GTmetrix for these examples because I like its interface, but the basic idea is the same across all the tools.

To get started, you go to GTmetrix and plug in the URL that you want to analyze. GTmetrix will give you a high-level look at the number of HTTP requests in the Page Details section, but you want the Waterfall tab for a deeper look:

GTmetrix resultsWaterfall analysisgood “waterfall chart for beginners” guide.

By looking at the URLs, you can start to understand what’s happening on your WordPress site.

For example, if you enter “wp-content/plugins” in the search box, you can see HTTP requests that plugins have added to your site. Specifically, the Lightweight Social Fonts plugin adds a 22.9 KB font request for “fontello.woff” that took 337 ms:

The waterfall analysis shows http requests on WordPressGeneratePress theme, which is pretty dang low because GeneratePress is so well-optimized:

WordPress http requestsmany WordPress image compression plugins.

2. Combine CSS and JavaScript Files

Thanks to your theme and plugins, your WordPress site will probably have lots of different CSS and JavaScript files. Again, each separate file is one HTTP request, so finding a way to combine those files together can cut down on your site’s HTTP requests.

To do this, you can use a technique called file concatenation, which is often paired with minification (another way to reduce the size of your code files).

Many WordPress performance plugins can help you concatenate files, including WP Rocket (our review). Or, you can use Autoptimize as a dedicated minification/concatenation tool.

3. Don’t Let Plugins Load Sitewide If Not Needed

You’ll probably have plugins that you only use on a few pages on your site. For example, if you have a contact form plugin, you probably use it on your contact page and nowhere else.

However, some plugins will load their assets, like CSS and JavaScript, on every page on your site, even if the plugin’s content isn’t present. For example, Contact Form 7 loads its scripts sitewide.

Essentially, this means that some plugins will add 1 HTTP requests to every single page on your site for no reason – not good!

If you absolutely must use a plugin that does that (rather than a more optimized alternative), you can use the Scripts Manager in the Perfmatters plugin to disable scripts on a page-by-page basis, which lets you force the plugin to only load its scripts on pages where you’re actively using it. Consequently, you can reduce HTTP requests on all the other pages on your site.

4. Remove/Replace Unoptimized Plugins

I’ve already covered the myth that using more plugins automatically means a slower-loading site.

However, using more unoptimized plugins will definitely slow down your site.

So, if you see a plugin with tons of slow-loading HTTP requests when you do your waterfall analysis, it’s worth thinking about whether or not you can:

  • Completely remove it from your site if that functionality isn’t necessary to the functioning of your site.
  • Replace it with a more lightweight option.

5. Consider Lazy Loading

Finally, to decrease the number of HTTP requests for a visitor’s initial page load, you can use lazy loading.

Lazy loading is a technique to delay loading certain “below-the-fold” assets (like images) until a user starts scrolling down.

Reduce WordPress HTTP Requests Today

In order for visitors’ browsers to load your site’s content, browsers need to send an HTTP request for every internal and external asset on your page.

All things equal, fewer HTTP requests generally means a faster-loading website, though you also need to factor in the size/time of each request.

To analyze the HTTP requests for your website, you can use the waterfall analysis feature in a WordPress performance testing tool like GTmetrix.

From there, you can follow the tips in this post to reduce the number of HTTP requests and speed up your site.

Any questions? Let us know in the comments!

error: Content is protected !!