You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What specific section or headline is this issue about?
No response
What information was incorrect, unhelpful, or incomplete?
Support for persistAcrossSessions in scripting.RegisteredContentScript was added and documented in Support for persistAcrossSessions #19196. However, this change didn't explain why developer might choose between persistent and non-persistent.
Notes for consideration:
Persistent is the default because the idea behind this API is that it's the dynamic version of the content_scripts key in manifest.json. Both registrations result in script executions at predictable* times, with the difference being that the new API allows an extension to dynamically (un)register scripts.
predictable as in runAt: "document_start" being respected; in contrast, when the (MV2-only) tabs.executeScript is used, the execution time is not guaranteed (hence the replacement of runAt with the injectImmediately option in the new scripting.executeScript API).
There are extensions that would like to have the script execution capabilities of registered content scripts, but not necessarily the persistent part of it. For example, if an extension (on behalf of a user) temporarily activated a content script with the goal of running it for content in the current session only. While it's not possible to restrict the registered content script to a specific tab, it is the closest that an extension can have if their goal is to schedule a content script for execution at the next load.
You should choose non-persistent for things that won't save over sessions, for example, counters. With a counter for a user on a website, if you want it to start at zero then it should just have a value of zero and not be persistent.
pransh15
added
p1
Major issue with medium priority, should be addressed soon.
and removed
p3
labels
Aug 28, 2024
MDN URL
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts
What specific section or headline is this issue about?
No response
What information was incorrect, unhelpful, or incomplete?
Support for
persistAcrossSessions
inscripting.RegisteredContentScript
was added and documented in Support for persistAcrossSessions #19196. However, this change didn't explain why developer might choose between persistent and non-persistent.Notes for consideration:
Persistent is the default because the idea behind this API is that it's the dynamic version of the
content_scripts
key in manifest.json. Both registrations result in script executions at predictable* times, with the difference being that the new API allows an extension to dynamically (un)register scripts.runAt: "document_start"
being respected; in contrast, when the (MV2-only)tabs.executeScript
is used, the execution time is not guaranteed (hence the replacement ofrunAt
with the injectImmediately option in the newscripting.executeScript
API).There are extensions that would like to have the script execution capabilities of registered content scripts, but not necessarily the persistent part of it. For example, if an extension (on behalf of a user) temporarily activated a content script with the goal of running it for content in the current session only. While it's not possible to restrict the registered content script to a specific tab, it is the closest that an extension can have if their goal is to schedule a content script for execution at the next load.
Although the specific topic is not clearly covered, this API design doc from Chrome may be helpful:
https://docs.google.com/document/d/1nRJ6iW-W1MVSpJnQzNrRQFLMsr0RycwsNym06TD5i18/edit
What did you expect to see?
Description of when to choose non-persistent over persistent.
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
The text was updated successfully, but these errors were encountered: