Short answer, we don't know. We haven't yet done good performance analysis of the impact of content scripts. We suspect that we should be able to make it fast, but don't know for sure yet.
Either way, we agree it is weird to run code in every page when it is really only needed in a few of them. We've been working on a new API that will allow an extension to decide programmatically to run a content script: http://sites.google.com/a/chromium.org/dev/developers/design-documents/extensions/executecontentscript-proposal - a On Wed, Sep 2, 2009 at 9:29 AM, Matias Pelenur<[email protected]> wrote: > > Hi, > I'm experimenting with a new extension that needs to read and modify > the DOM of arbitrary pages. I use a background page to keep track of > what pages need to be modified, and a content script that communicates > with the background page via ports. > > The content script is set to match all URLs (http://*/*) and includes > a fairly large chunk of JS, over different files. But the first thing > it does when executed is ask the background page if it needs to do > anything for that particular page. It only calls additional JS > functions if it needs to. > > Is this, in general, a bad idea, since it's executing for every single > page, even though it only needs to act on a few? As far as I can tell > from the docs, the only way to traverse or modify the DOM of a page is > through a content script. I can subscribe to events from the > background page that tell me when pages are loaded into the various > tabs, but I don't see a way from there to get access to their DOM, or > to inject a content script into those tabs at runtime (which would be > nice to do). > > Perhaps this is all unnecessary and it's perfectly fine to always > inject content scripts into every page. But so far my extension seems > to break Gmail (it loads but doesn't do anything else), and I wonder > if the content script is what's killing it. > > Thanks, > matias > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Chromium-extensions" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en -~----------~----~----~----~------~----~------~--~---
