0

Currently in MV3, Chrome supports Service worker while Firefox & Safari opted for Event pages.

SW in MV3 is discarded and then restarted and all variables are reinitialised.

  • What happens to variables in event pages?
  • Do they have to be recreated every time the event fires (within event callback)?
  • What are the practical differences between SW & EP in extension development?
erosman
  • 7,094
  • 7
  • 27
  • 46
  • 1
    It's the same as event page. The main difference is the lack of DOM and other foreground-only API. The entire script executes in both cases, not just the event listener, so your variables will be new each time, [more info](https://stackoverflow.com/a/73208288), see also [how listeners work](https://stackoverflow.com/a/74516519) in SW and event pages. – wOxxOm Feb 22 '23 at 13:18
  • @wOxxOm Thank you. Since EP has more functionality than SW, a background SW written for Chrome extension should work on Firefox without any hassle, shouldn't it? – erosman Feb 22 '23 at 15:47
  • 1
    Yes, if you don't use SW specific events (onfetch, oninstall, onmessage). – wOxxOm Feb 22 '23 at 17:04

0 Answers0