In Chrome DevTools, how do you test a page with one script missing or an API returning different data, without changing the server?
answer
- right-click the row in Network
- a rule in a drawer tool
- URL Pattern syntax
- a local folder holds the edits
- a filter shows what you changed
basics
~20 sBlock the script by right-clicking its row and choosing Block requests, which adds a rule in the Request conditions drawer. Change an API's response with Override content or Override headers, which serve your local edits from a selected folder.
solid answer
~40 sTo remove a resource, I right-click its row in the Network panel and use **Block requests**, then **Block request URL** or **Block request domain**. That adds a rule to the **Request conditions** drawer, which older guides call Network request blocking, and rules there use URL Pattern syntax. The row then shows `(blocked:devtools)`, and I watch how the page copes. To change a response, I right-click the API call and choose **Override content** or **Override headers**. The first time, DevTools asks for a local folder; the edited copy lives there, and on reload the page gets my version. I find active changes with the `has-overrides:yes` filter. All of this affects only my own browser, so it is safe for trying out a failure or a fix before anyone touches the server.
go deeper
Recall that you can right-click a Network row to block it or to override its content, and that this affects only your own browser.
Explain the mechanics: rules in the Request conditions drawer use URL Pattern syntax, overrides are local files in a folder you choose, and a blocked call looks like a network failure to the page.
Use these to prove resilience before a dependency fails for real: block each third party, check for fallback behaviour, and try a future API shape with an override before the backend changes.
Consider whether a team should write failure checks like this into its release routine: blocking each third party on key pages is cheap, while finding an unhandled dependency during an outage is not.
## Two questions, two tools Some bugs only show up when something goes wrong elsewhere: a third-party script is down, or an API starts returning a shape the page has never seen. You can test these without a server change or a deploy, because the Chrome DevTools Network panel can intervene on your own traffic. - **Request blocking** answers "what happens if this never arrives?" - **Response overrides** answer "what happens if this comes back different?" Both are started from the right-click menu on a request row, and both affect only the browser you are working in. Real users see nothing. ## Blocking a request Right-click a row and open the **Block requests** submenu. It holds two items: 1. **Block request URL** adds a rule for that exact address. 2. **Block request domain** adds a rule for the whole host, which is handy for a third-party script with many files. Each rule goes into the **Request conditions** tool in the drawer. Older tutorials call it Network request blocking, and the current name reflects that the same tool now also throttles. Rules there follow **URL Pattern syntax**, so you can write one that matches a family of paths. A checkbox named `Enable blocking and throttling` switches them all off at once, and each rule shows how many requests it has affected. Reload the page and three things tell you it worked: - The row's Status reads **`(blocked:devtools)`**. The word after the colon is the reason, so `(blocked:origin)` or `(blocked:csp)` means something else stopped it. - The **Blocked requests** option under the filter bar's More filters lists only the stopped requests. - The page's own error handling runs, because to the page a blocked request looks like a network failure rather than an HTTP error. A `fetch` rejects, and a script tag fires its error event instead of its load event. That last point is what you are testing. Good code renders a fallback; fragile code leaves a blank screen. ## Overriding a response Right-click an API call and choose **Override content** to replace the body, or **Override headers** to change response headers. 1. The first time, DevTools asks you to select a folder and grant it access. Overrides are stored there as ordinary local files. 2. For content, you land in an editor in the Sources panel with a copy of the response. Change it and save. 3. For headers, you land in the **Response Headers** section of the request's Headers tab. A button named **Override header** on each value makes it editable. 4. Reload. DevTools now gives the page your version. | Use case | Tool | |---|---| | The third-party widget is down | Block request domain | | The analytics script fails to load | Block request URL | | The API returns a new or unexpected field | Override content | | A response header needs to be tried out | Override headers | | One endpoint is slow | Throttle request URL, in the same right-click menu | ## Finding what you changed Overrides and blocks stay active until you remove or disable them, and a forgotten one produces very confusing bugs later. Three aids help: - **The `has-overrides` filter** takes `yes`, `no`, `content` or `headers`, so `has-overrides:yes` lists everything being replaced. - **The Has overrides column** can be added to the request table and shows the override type on each row. - **Show all overrides** in the right-click menu jumps to the list in the Sources panel, where you can turn them off or delete them. ## Limits to keep in mind - **Your browser only.** Teammates and users are unaffected, so neither tool demonstrates a fix on production; they let you try one before writing it. - **Source-mapped files are redirected.** If you choose Override content on a source-mapped file, DevTools sends you to the deployed file rather than the original source. - **Some addresses are off limits.** The override commands are disabled for URLs that DevTools treats as non-overridable. - **Setup lives elsewhere.** Managing the overrides folder and mapping a project into a workspace belong to the Sources panel, covered with local overrides and workspaces. Used together, these two tools let you turn "what would happen if the API changed?" from a meeting question into five minutes of evidence, and you can capture the result before asking a backend team to do anything.
- What does a page's code see when Chrome DevTools blocks one of its fetch calls?A network failure rather than an HTTP error. The `fetch` promise rejects and no response object arrives, so `response.ok` checks never run. That makes blocking a good test of a page's `catch` path, whereas an error status would exercise its branch for a response that did arrive.
- How do you slow one endpoint instead of blocking it entirely?Use the **Throttle requests** submenu on the same row, choosing **Throttle request URL** or **Throttle request domain**. The rule goes into the same Request conditions drawer, where you can change its speed. Only matching requests slow down, and the row's Timing tab then marks the request as throttled by that rule.
- Believes a DevTools override changes what other users or the server receive.
- Says the drawer tool is still named Network request blocking.
- Expects a blocked fetch to resolve with an error status such as 404.
- Forgets active overrides, then spends hours debugging a response nobody else sees.
- Says a rule in Request conditions can only block a request, never slow it.