Chrome Dev Tools - Modify javascript and reload
Need a quick win? Just trigger Chrome's Local Overrides. Right in Chrome Dev Tools > Sources, right-click on the desired JavaScript file, select Save for overrides, tweak the code, hit Ctrl+S
(Cmd+S
on Mac). Upon page refresh, your edits will stick around.✨
Example:
- Fire up Chrome Dev Tools, switch to Sources.
- Right-click on the required file, Save for overrides.
- Edit the code, signal with
Ctrl+S
(Cmd+S
). - Refresh to observe your persistent changes.
Deep dive: unlocking local overrides potential
Beneath Chrome Dev Tools architecture lies a feature gem — Local Overrides! This time-saver enables you to see realtime changes without refiring a new development build. Configuring a local directory for overrides, the changes persist on your disk, supporting your hotfix experiments across sessions.
Setting up local overrides: a step-by-step guide
Here's the insider's guide to enabling this powerful feature:
- First, open DevTools, then access Settings (the gear icon at the top-right corner) or simply
F1
. - Make that Local Overrides option under Experiments ticked.
- Find your way to Sources, then navigate to the Filesystem tab within the panel. Now set up your local directory by clicking
+
. - Permit Chrome to enjoy its read/write access to the directory you defined.
- Choose your file, right-click, and click on Save for overrides to create a local copy for edits.
Extensions and tools for better control
Longing for specialized control or needing a fit in an already established workflow? Resource Override extension or Fiddler's AutoResponder might be the exact kit. Each offers ways to maintain edits even after reloading.
Resource Override steps:
- Install the extension from the Chrome Web Store. (Could they make it any easier?)
- Set file rules for specific files to redirect to local files on your disk. (Because who wouldn't want control?)
- Changes made to local files stay even after page refresh. (Persistence pays, right?)
Fiddler AutoResponder steps:
- Run Fiddler and ensure a proper configuration for HTTPS traffic.
- Open the AutoResponder tab in Fiddler.
- Create a rule in AutoResponder to divert the traffic for a selected JavaScript file to your local edited version.
Troubleshooting and key problem areas
Unforeseen confrontations in the real world of modifying JavaScript:
- Not persisting override: Confirm overrides directory permissions are set right and Chrome points to the exact directory.
- Lost breakpoints: Don't forget to verify breakpoints after changes.
- Decreased performance: Keep a balance. Excessive use of overrides can affect debugging speed. Regular health checks are good for your process.
Best practices for local modification
- Backup is your best friend: Always shield your original files — save backup before venturing into changes.
- Embrace version control: Keep your code changes under surveillance with Git or another version control system.
- Test like there's no tomorrow: Test your changes. Local Overrides is not a replacement for a proper development or staging environment.
Was this article helpful?