background.js threading architecture

465 views
Skip to first unread message

Jordan McDonald

unread,
Oct 20, 2013, 1:39:13 PM10/20/13
to chromium-...@chromium.org
Hey All,

Is the background.js architecture a single thread?   For example if i have injected some code into the page via content scripts will have two + tabs open will there be thread contention with the background thread?   

It seems that when I refreshes two tabs about the same time only one of them seems to get all the elements populated.  I am wondering if I need to adjust my code or if by design the background process is single threaded.

Bigger questions is do I need the background.js or can i do everything with content scripts and my extension code?

Thanks
Jordan

Jeffrey Yasskin

unread,
Oct 21, 2013, 12:39:11 PM10/21/13
to Jordan McDonald, Chromium-extensions
All Javascript is single-threaded, but multiple callback chains can
interleave with each other. Different tabs effectively live in
different processes that are sometimes allowed to exchange messages,
and the background page is, similarly, a separate process from any
tab.

Javascript running in a content script can't do everything that
javascript running in a background page can:
http://developer.chrome.com/extensions/content_scripts.html.
> --
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to chromium-extens...@chromium.org.
> To post to this group, send email to chromium-...@chromium.org.
> Visit this group at
> http://groups.google.com/a/chromium.org/group/chromium-extensions/.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/bb2e5720-8117-4c47-8786-562dae315428%40chromium.org.
> For more options, visit
> https://groups.google.com/a/chromium.org/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages