简体   繁体   中英

How can a Google Chrome extension exit its own background process?

My goal is very simple: when the user installs the extension, open the options page.

The only way I know how to do that is to create a background page, and on that page check for localStorage.setup. If it is not present, set it to true and open the options page. This approach works, but, besides being convoluted, it's inefficient. Not only will the background page load every time the user opens the browser, but it will constantly be running in the background.

Is there any way to tell chrome the background page is finished, and should be exited? Or is there any way for an extension's background page to prevent itself from being loaded in the future? Or, is there a better way to solve my problem?

With transient background pages , the background page will exit automatically once all code that it's running finishes. This feature will be in a future Chrome release, but since it's still under active development, there isn't documentation for it yet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM