Refreshing content.js

48 views
Skip to first unread message

PageShield

unread,
Dec 15, 2025, 3:34:26 PM (20 hours ago) Dec 15
to Chromium Extensions
Good Afternoon

Often the content.js script is not updated with my latest changes when coding. This is even so after I try:
1. Open Chrome Inspect > Hold down the refresh button, then select 'Empty Cache and Hard Reload'
2. Hold down the 'View site information' button on the URL bar and select: 'cookies and site data' and then 'manage on-device site data' and then delete all cookies
3. Reload the extension from chrome://extension 
4. Remove and then re-unpack the extension on chrome://extensions

How can I ensure that I am always running the latest content.js, or the latest JavaScript files from any site that I am working on?

Thank you

woxxom

unread,
2:49 AM (9 hours ago) 2:49 AM
to Chromium Extensions, PageShield
The correct sequence is:
1. reload the extension
2. reload the web page

Instead of #2 you can re-inject content scripts using chrome.scripting.executeScript (https://stackoverflow.com/a/11598753) and "unregister" the old ones using a DOM event (https://stackoverflow.com/a/57471345). You can also add a "Reload extension" button to your UI or to the context menu in dev builds of your extension so you won't have to keep a chrome://extensions page open all the time.
Reply all
Reply to author
Forward
0 new messages