We currently inject content scripts into <all_urls> to check if the current URL matches any user scripts. This is somewhat wasteful of resources and could impact the efficiency of all tabs that don't require user scripts.
A better approach is to avoid using <all_urls> and instead use contentScripts.register() to dynamically register to the matching list of all user scripts.
One challenge is that if user scripts use regular expression matching, it cannot be converted to match patterns for registration.
This is also one of reason that why I previously suggested deprecating @include and @exclude metadata.
One possible backward-compatible approach is to fall back to <all_urls> if one of the user scripts uses a regular expression. Otherwise, we can register it in the matching list for all user scripts.
While this adds a little complexity, it's worth it for the overall resource savings.
We currently inject content scripts into
<all_urls>to check if the current URL matches any user scripts. This is somewhat wasteful of resources and could impact the efficiency of all tabs that don't require user scripts.A better approach is to avoid using
<all_urls>and instead usecontentScripts.register()to dynamically register to the matching list of all user scripts.One challenge is that if user scripts use regular expression matching, it cannot be converted to
match patternsfor registration.This is also one of reason that why I previously suggested deprecating
@includeand@excludemetadata.One possible backward-compatible approach is to fall back to
<all_urls>if one of the user scripts uses a regular expression. Otherwise, we can register it in the matching list for all user scripts.While this adds a little complexity, it's worth it for the overall resource savings.