Is it possible for a chrome extension popup not to wait for background scripts to load?

时间:2018-02-01 18:29:26

标签: google-chrome-extension

Intro

I have a chrome extension I am working on, that uses the background page to listen to the following window and tab events:

chrome.tabs.onActivated
chrome.tabs.onUpdated
chrome.windows.onFocusChanged

The background process basically retrieves the HTML source from each qualifying page the user visits, via a content script injection and messaging. Once the message with the HTML source is received in the background page, it performs specific tests which may take anywhere from few to several of seconds, depending on the source size.

The Problem

I found that each time I click on the extension icon to open the popup.html view, it renders my background page again and runs the HTML collection and analysis. The issue is the popup view window doesn't open until the background has finished, which on certain pages may take 5-10 seconds.

I tried running the entire background page async with setTimeout(function(){..},0) which didn't work..

How can I solve this?

  • Is there a way that the popup page will not render the background again? This happens anyway when the user views the tab, so I don't need it?
  • If not, is there a way for the popup to display regardless of the background operation?
  • any other suggestions?

Thanks!

0 个答案:

没有答案