I am trying to work out how to use Google Chrome DevTools to simulate a timeout on a JavaScript file on my site.
I can use the 'Toggle Device Mode' to introduce throttling but that doesn't target a specific script.
Is there a way to do this with DevTools?
I am using Chrome 38.
In Chrome you can setup a new network profile with custom download/upload bandwidth and latency time.
Use a long enough latency value to trigger a request timeout.
DevTools technical writer and developer advocate here. As of January 2018:
Haven't tested this code, but something like this might work for the service-worker-based throttling:
self.addEventListener('fetch', event => {
const TARGET = 'example.com';
const DELAY_MS = 1000;
if (event.request.url === TARGET) {
setTimeout(() => {
event.respondWith(caches.match(event.request));
}, DELAY_MS);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With