It can be helpful to make quick changes to the source code that a site uses, especially when debugging a site in production. For example, if you suspect that a bug is caused by a specific line of code, and you want to test a fix, it can be faster and easier to make the required change temporarily on the production code directly, rather than setting up a local development environment.
Chrome, Edge, and Firefox allow you to temporarily override any source file that a site uses with files stored locally on your computer.
Note that the files are only overridden while DevTools is open, and no changes are made to the original files on the server.
Override files in the Firefox DevTools Debugger tool #
-
In Firefox DevTools, open the Debugger tool.
-
In the Sources panel, find the file that you want to override.
-
Right-click the file and select Add script override.
A file explorer window opens.
-
Choose a location for the file override and submit.
-
Make changes to the local file stored at the location you chose.
-
Refresh the page in Firefox to see the changes.
Override files in the Chrome or Edge DevTools Sources tool #
-
In Chrome or Edge DevTools, open the Sources tool.
-
In the right pane, open the Overrides tab. You might need to click the More tabs chevron icon to see that tab.
-
Click Select folder for overrides.
A file explorer window opens.
-
Choose a folder for the file overrides to be stored in, and then submit.
DevTools requests your permission to access the file system, click Allow.
-
In the right pane, open the Page tab.
-
Find the file that you want to override and click it.
The file content appears in the editor.
-
Make changes to the file content, and then save the file.
The changes get saved locally within a subfolder of the folder you chose. The subfolder is named after the domain of the site you're debugging. If you go to another site and override a file from that site, the overrides are stored in another subfolder of the folder your chose.
-
Refresh the page in Chrome or Edge to see the changes.