Local Overrides - Unleashing Full Potential of Chrome Devtools

Sajeesh Kumar A
Villa Plus Engineering
4 min readJul 2, 2024

As web developers, we’re all familiar with Chrome DevTools’ essential features such as the Elements panel for DOM inspection and manipulation, the Console for debugging JavaScript, the Network tab for HTTP traffic monitoring, and the Performance panel for load time optimization are all known to us as web developers. These fundamental tools are now essential to our everyday operations.

But Chrome DevTools is much more than just these core functionalities. It’s a complete toolkit with potent, frequently disregarded features. These include Lighthouse for thorough site auditing, Workspaces for real-time local file editing, Remote Debugging for testing mobile devices, and Network Request Blocking for mimicking resource unavailability.
Gaining proficiency with these advanced features can help you boost debugging efficiency, streamline your development process, and understand your web apps on a deeper level.

Overcoming Development Obstacles

As developers, we often encounter scenarios that seems to be a obstacle for our development process. Consider these common yet frustrating situations:

1. The Unyielding iframe

You run across a roadblock when working on a feature that needs an iframe to load. The iframe cannot load in your local environment due to a strong Content Security Policy (CSP). The CORS parameters on the server-side are tightly controlled and cannot be altered. You are unable to test essential functionality since your local development comes to a complete stop.

2. When the simple path becomes difficult

A serious problem appears in the CSS or JavaScript of your live website. You want to try the fix there immediately before making the fix from your code. You will jump into DevTools’ Sources panel, make the required changes, and exhale with relief as the problem goes away. However, your triumph is fleeting, as a mere page refresh erases your modifications, and the bug reappears like an unwanted visitor.

A recurring characteristic among these cases is the requirement for local and permanent control over remote or production resources. Developers require a more potent approach when temporary DevTools modifications are insufficient and server configurations are unreachable.

Fortunately, Chrome DevTools has an ace up its sleeve - a feature that allows you to take control of these seemingly uncontrollable situations. With the help of this tool, you may persist changes between page reloads, override remote resources with local files, and get around stringent security regulations for testing reasons.

Introducing Local Overrides: Your Development Superpower

Chrome DevTools’ Local Overrides feature allows you to replace network resources with local files, solving many of the challenges we’ve discussed. Here’s how to use it:

Setting Up Local Overrides:

Local overrides
  1. Open Chrome DevTools
  2. Go to the Sources tab
  3. Look for the Overrides sub-tab (if not visible, click >> to find it)
  4. Click “Select folder for overrides” and choose a local folder
  5. Allow DevTools to access the folder when prompted

Overriding Headers :

Network tab UI for editing headers
  1. Go to the Network tab in DevTools
  2. Right-click on the request you want to modify
  3. Select “Override headers”
  4. Add or modify headers as needed (eg: to bypass CORS restrictions)
  5. The changes will persist across page reloads
Override applied for CSP header applicable to all requests (* refers all requests).

Overriding Content:

  1. In the Sources tab, navigate to the file you want to override
  2. Make your changes in the DevTools editor
  3. Save the file
  4. DevTools will prompt you to allow the override
  5. Refresh the page, and your changes will persist

Your modified version of the file will now be used instead of the one served by the website, allowing you to test your fix thoroughly.

With Local Overrides, you can now easily test iframe integrations with modified security headers and implement persistent changes to production code for debugging and hotfixes.

Conclusion

There’s more to Chrome DevTools than just a collection of simple debugging tools (Any browsers based on Chromium can support these functionalities). This robust suite has the ability to completely change your web development workflow. You can get around common development obstacles, close the gap between local and production environments, and improve workflow by utilizing sophisticated capabilities like Local Overrides.

--

--