How to Make Fewer HTTP Requests

24 May, 2021 Technical
How to Make Fewer HTTP Requests

Whenever someone clicks to visit your website, their browser sends a request to your server. This is known as an HTTP request. HTTP requests are in some way connected to page speed. The more HTTP requests being made, the longer the page takes to load in someone’s browser. Once all the requests have been made and the files have been loaded, someone can view and interact with your site. In order to make your page load faster, your page needs to make fewer HTTP requests. So how do you do that?

First, you should test to see how many HTTP requests are occurring so you know how many improvements need to be made. Web tools like Pingdom and GTmetrix can perform these tests for your site. Once your site has been scanned, you can see how many HTTP requests there currently are. After this is complete, you can move onto the following technical optimization steps to make fewer requests.

1. Remove Unnecessary Plug-ins

Plug-ins can be very helpful for a website, as they add new functionality and can make your page more engaging. However, too many plug-ins can make your site cluttered and cause loading times to increase. The general rule of thumb is to keep your plug-ins to a minimal amount and avoid ones that use external requests from other websites, run ongoing processes, or take a long time to load. Identify the plug-ins that are essential, and if some are not, it may be best to deactivate and uninstall them.

2. Remove Images You Do Not Need

Images are a good way to make your site more visually appealing and draw your reader’s attention. However, every image creates an HTTP request, and these can add up. Unless an image is adding significant value to your page, it may be worth deleting. Not only will this improve your loading times, but it may also keep visitors from leaving your site just because images aren’t loading.

3. Reduce the File Size of Remaining Images

After you have gone through your images and decided which ones you would like to keep, it’s time to optimize them. Try compressing your images to reduce their file size. Smaller files means shorter HTTP requests. Be careful; reducing file size sometimes reduces the quality of the photo, so make sure you are finding the right balance.

4. Get Rid of Videos

Similar to the image dilemma, videos can add interest to your page but increase your loading time. Each video creates an HTTP request, so it is important to minimize the videos you choose to display on your page to only ones you find necessary and valuable to the user’s experience. Otherwise, unnecessary videos should be deleted.

5. Enable Lazy Loading

Lazy Loading means a page won’t load images or videos until the user starts to scroll down your page. This allows websites to load faster because it ensures that only what is immediately displayed on the screen will be loaded initially. Using Lazy Load means an HTTP request won’t be made for the initial page load and the user experience won’t be affected.

6. Content Caching

Caching is an easy way to reduce HTTP requests. Caching means a visitor’s browser will store a copy of the page’s script used to display the site. When a visitor returns to the site, the HTTP requests don’t have to be made again because the scripts have already been saved in their browser. Some other tips for caching are to avoid cookies unless they are essential, use the same URL for content across different pages, and build up a library of images or videos and reuse them.

7. Reduce Third-Party Requests

If your page requires a user’s browser to request or download data from a third party to display on the site properly, it’s a third-party request. These requests depend entirely on how quickly the third-party server responds, and it is out of your control. This is where lazy loading can be beneficial, such as embedding videos into your site. Hosting scripts for necessary programs such as Google Analytics locally rather than externally could be beneficial as well. If a plug-in makes third-party requests, it may be best to either switch to a different plug-in or delete it from your page.

Making some or all of these small changes to your site can not only help reduce the number of HTTP requests you have but also improve the user experience. Remember, fewer requests means less loading time and more user satisfaction.

Sign up for Our Newsletter