Delay Network Requests
Add delay to your network requests
As a frontend developer or QA, Testing certain parts of web applications require you to simulate delay in one or more components of the web app.
- Test performance of your web app on a slower condition
- Test behaviour of your app when one or more APIs respond slow (API Latency has gone up)
- Check if any race conditions exist when some resource X gets loaded after/before another resource Y.
- Test the impact of slow loading of external resources impact on your app.
- Test your loading experience in the app.
It is important for a developer to test the website performance in poor network conditions. This article focuses on the different methods which could enable developers to simulate network conditions.
The network tab in DevTools provides an option to throttle network requests. With this you can experience the same network conditions what one might face when using slow 3G, 2G connections or offline.
Steps to use the throttler:
- Open DevTools (Ctrl + Shift + I)
- Switch to the Network Tab.
- By default, the throttler is set to ‘No Throttle’.
- From the dropdown menu, you can select the type of network to simulate.
- Long Press the reload icon while the DevTools panel is open.
Long press the reload icon to see advanced reload options
- Select ‘Empty Cache and Hard Reload’ from the advanced reload options.
It is important to empty cache to examine the page as a first time visitor.
- It throttles the entire network. It is not possible to delay a particular network request.
- It might not be helpful in cases where you want to selectively delay network requests.
How to use the API:
Change the link to be delayed as:
For example - Suppose you want to delayhttps://code.jquery.com/jquery-3.6.0.slim.jsby 4000 ms and see the impact on your app as your libraries heavily depend on jQuery. This url has to be changed to :
Requestly delay rule works primarily on client side. This is how you can create a Delay Request Rule.
Selecting Delay Rule in Requestly
Configuring Delay Rule in Requestly
- It supports delaying multiple requests which contain a certain keyword or match against the regex.
- It also works with AJAX requests.
You can also combine this with other rules of requestly, which is helpful in many situations, like somewhere you want to modify the headers of the request after delaying it. It could be easily solved using requestly.
If you want to add delays for network traffic in Android apps, use our Android Debugger
- The Requestly extension actually adds the delay in the browser.
- Adding the delay in the browser could lead to poor browsing experience when the delay is applied to too many requests or it is applied for a large duration.
- To test your entire application on a slower network, prefer using the browser's network throttling feature.
- To add delays to external resources like CSS, JS etc prefer using Server Side delay.
- To add delays to API requests (& AJAX requests) prefer using Client Side delay.