0

We're currently developing a chrome extension, and one question that was raised was do content scripts remain connected to background script if the user updates his extension to a new version?

Does both background script and content script gets reloaded?

The.Wolfgang.Grimmer
  • 1,172
  • 2
  • 9
  • 32

1 Answers1

0

Yes, entire extension is being restarted. However content scripts don't get removed/restarted until page they are running in is refreshed.

vanowm
  • 9,466
  • 2
  • 21
  • 37
  • Thanks, I see, in that case what the best way to also update the content script once the extension has been updated? – The.Wolfgang.Grimmer Jul 22 '21 at 23:08
  • Perhaps a background script could send a message to content script to refresh the page? https://stackoverflow.com/questions/22516195/how-to-properly-handle-chrome-extension-updates-from-content-scripts – vanowm Jul 22 '21 at 23:09
  • The old content scripts can't send messages. Their sendMessage or any other `chrome` method will throw an exception. See [Chrome extension: How to remove orphaned script after chrom extension update](https://stackoverflow.com/a/57471345) and [Chrome extension content script re-injection after upgrade or install](https://stackoverflow.com/q/10994324) – wOxxOm Jul 23 '21 at 02:20