Whenever someone visits a page on your site, the browser has to request lots of files. These HTTP requests have a direct impact on how quickly the web page loads.
Generally, fewer HTTP requests mean a faster loading website.
The loading speed of a website is now an important search engine ranking factor. On average, the media page loading speed for Google’s 10 results is just 1.65 seconds.
This highlights the importance of having a fast-loading website. The top results on the Google search engine results pages (SERPs) load in less than two seconds.
You can learn more about HTTP requests and how they impact the loading speed of a website this video.
The total number of HTTP requests a site has to deal with can have a massive impact on the overall loading speed. You can make a significant change in how fast your site loads by reducing HTTP requests.
Here are 8 ways of reducing the number of HTTP requests and increasing the loading speed of your website.
1. Delete unnecessary images
As we just discussed, more files mean more requests.
The goal, therefore, is to minimize the number of files and images a web page has to load. This, in turn, reduces the number of HTTP requests and may improve the loading speed of the web page.
There are two points to note here:
- Clean your media library and delete any unnecessary images. You’ll be surprised to find many images that you probably don’t even use anymore. For example, images used on web pages that don't exist anymore.
- Do not sacrifice images just for cutting down on HTTP server requests. The idea is to delete unnecessary images, not minimize the number of images you’d normally use.
Once you have dealt with images, take a look and delete some other unnecessary files. For example, it could be an embedded video or a third-party social media feed plugin.
Identify the different elements your web page uses and then pick the ones that aren’t necessary but hog your resources. Get rid of them and improve the loading speed of your site.
2. Reduce image size
You may have deleted a reasonable amount of images. However, there would still be plenty of images left. And you can’t get rid of them. You shouldn’t.
Therefore, the next step is to reduce the file size of those images that you are going to use on your web pages.
You can use plugins like WP Smush plugin and EWWW optimizer to compress the size of the images you use. Moreover, it is also highly recommended to use web-friendly images. For example, use .jpg images instead of .png whenever possible.
Reducing image size is one of the most fundamental techniques to increase the loading speed of web pages.
It is also recommended to leverage image caching to further reduce the server load and improve website speed. Watch the following video to learn more about image caching.
3. Implement the lazy loading technique
You must have heard of the lazy loading technique, right?
In case you haven’t, here is a brief explanation of what it is and how it works.
A page may have many images. When a user visits that page, your site sends HTTP server requests for all those images. Depending on how heavy your web page is, this may slow it down.
However, what if the user never even intended to scroll down to the bottom of the page and see all those images?
The lazy loading technique solves that problem.
Instead of sending unnecessary HTTP requests, this technique only sends server requests when a user scrolls down to an image on the page.
Smart utilization of resources with the lazy loading technique can significantly reduce the number of HTTP requests and improve the loading speed of your site.
4. Ignore irrelevant assets on the page
Ignoring relevant assets on a web page works similarly to lazy loading.
Lazy loading, as we just discussed, delays sending the server requests for unviewed images.
Similarly, you can install plugins like WP Asset Cleanup Plugin, which would detect plugins and files that exist within your website theme but on a specific page. Once such files are identified, the plugin would prevent them from being loaded on the page.
This is another smart way to reduce the number of HTTP server requests without sacrificing the quality of your web page.
5. Minifying CSS and JavaScript files
Minification is an important technique used to increase the loading speed of a website.
It means removing unnecessary code that is not necessary to execute — for example, unnecessary characters, white space, comments, etc. — from CSS, JavaScript, and HTML files.
6. Combine CSS and JavaScript files
Just like minification, combining CSS and JavaScript files is also a very good technique to reduce the total file size of your website.
The idea is to combine all your CSS and JavaScript files into one separate file each. For example, if your website has 4 external JavaScript files and 3 external CSS files, it would mean 7 requests.
However, if you combine the 3 CSS files into one CSS file and the 4 JS files into one JS file, your site will send only 2 requests instead of 7.
Minifying and combining CSS and JavaScript files is an effective way to reduce the number of HTTP requests and increase the loading speed of your website.
7. Minimizing the number of external scripts
It is also highly recommended to identify all the other files that are adding requests. You can do that in the Google Chrome Network panel.
It is not uncommon for external scripts to increase the number of HTTP requests. For example, it could be a social feed plugin by Twitter, Gravatar, or marketing scripts that are no longer in use, adding a couple of seconds to the load time.
By identifying the exact third-party integrations and external scripts that are slowing down your website, you can make a well-informed decision regarding which assets to keep and which to sacrifice.
8. Use a Content Delivery Network (CDN)
If you are still struggling to keep the number of HTTP requests down to a reasonable level, we recommend using a content delivery network (CDN).
A CDN is a network of servers located in several different parts of the world. CDNs cache static content on your website and then serve that cached content whenever a user visits your site. The cached content is delivered from the server that is closest to the user’s physical location.
Whether you want to use a CDN or not depends on several things. The most important is whether your traffic is local or international. If most of your website visitors are local, a content delivery network is not necessary.
If users from all over the world visit your website, a CDN can be very useful in speeding up your website.
Conclusion
HubSpot suggests keeping the number of files between 10 and 30. This may not be entirely possible for large websites with lots of content, images, and high-quality videos, but it is still a good benchmark for most websites.
Identify exactly how many HTTP requests your website makes and then work your way down by strategically analyzing each element.
This will help you reduce the number of HTTP requests, increase the loading speed of your site, and potentially improve user retention, engagement metrics, conversion rate, and online sales.