DEV Community

Cover image for How to make fewer http requests in wordpress
Chetan Rohilla
Chetan Rohilla

Posted on • Edited on • Originally published at w3courses.org

How to make fewer http requests in wordpress

Some times your website may be slow due to high number of http requests because more http requests increases the server response time or dns lookup time, increases the webpage load time and increases the DOM or webpage size and also uses the user’s more internet data.

So, here below is the steps for how to make fewer http requests in wordpress and also you can reduce your dns lookups:

Step 1 – Compress, Minify and combine your website resources to make fewer http requests

Compress or Minify your website resources like CSS, Javascript and then combine your minified or compressed files into one or two files. To do this there are number of wordpress plugins like WP-Optimize – Clean, Compress, Cache, LiteSpeed Cache. Through this plugins you can also optimize or speed up your website and images.

Step 2 – Remove unused website resources

Remove unused resources like css, javascript or images from your website.

To do this you can go to your theme folder located at website_root_path\wp-content\themes\your_theme and open your header.php and footer.php file and remove the css or js files which is not useful.

And also we have created tutorial for how to remove javascript or scripts in wordpress, how to remove css or styles in wordpress you can also use these tutorials.

Also remove unused images from your wordpress posts or pages and to remove unused images from your media you can use Media Cleaner, WPS Cleaner.

Step 3 – Remove links from sidebar, widgets, header or footer

And you can also remove or disable your wordpress widgets like footer widgets or sidebar widgets, header menu links, header widgets, header links, breadcrumb links, sidebar links.

And to do this by coding you can follow this tutorial how to optimize wordpress for mobile through this tutorial you can disable or remove some modules for desktop or mobile website.


Please like share subscribe and give positive feedback to motivate me to write more for you.

For more tutorials please visit my website.

Thanks:)
Happy Coding:)

Top comments (1)

Collapse
 
ahmedarain3 profile image
ahmedarain3

Reducing the number of HTTP requests in WordPress can help improve your site's performance and load times. Here are some strategies you can use to achieve this.

Combine and minify CSS [removed]
Reduce the number of external CSS and JavaScript files by combining them into one file. It also minimizes the combined file to remove unnecessary characters and optimize its size. Plugins like Autoptimize and WP Rocket can be used to automate this process.

Use a content delivery network (CDN).
The CDN stores its website's static files on multiple servers around the world and allows visitors to download the static files from the server closest to their location. This reduces latency and reduces the number of requests to your origin server. Popular CDN services include Cloudflare, MaxCDN, and KeyCDN.

Enable caching:
Use a caching plugin like WP Super Cache or W3 Total Cache to generate a static HTML version of your dynamic WordPress site. Visitors can be served cached pages, reducing the need for dynamic page generation and database queries.

Lazy load image:
Implement lazy loading of images. This means the image will only load when the user scrolls down the page. This technique reduces the number of initial requests and speeds up the initial page load. WP Rocket's Lazy Load and Lazy Load Optimizer are some of the WordPress plugins that can be used for this purpose.

Minimize external requests.
Reduce the number of external resources such as fonts, scripts, and widgets your website loads. Evaluate whether each resource is necessary and consider alternatives or remove it if it is not critical to site functionality.

Inline Small CSS and [REMOVED]
For small snippets of CSS or JavaScript code that is only used on a specific page, consider including them directly in your HTML code instead of making separate requests. Lazy or load scripts asynchronously.
Defer the loading of scripts that are not critical to the first render of the page, or load them asynchronously. This allows the rest of the page to load without waiting for the script to download and run. Plugins like Async JavaScript and WP Rocket can be used to handle script loading asynchronously.

Optimize fonts.
When using custom fonts, minimize the number of font variations and weights loaded. Also, consider using system fonts or hosting fonts locally to avoid external requests. Check and optimize your plugins.
Evaluate your installed plugins and disable or remove plugins you no longer need. Some plugins can add additional CSS or JavaScript files to your page to increase the number of HTTP requests.

Always test your site after implementing these adjustments to ensure that there are no issues or conflicts with your site's functionality.