simonwjackson
simonwjackson

Reputation: 1878

Can a Google Chrome extension detect when all scripts finish loading?

I want to develop a Chrome extension that scrapes data off the page, but this can happen only after all of the pages ajax finish loading their remote content.

Is this possible?

Upvotes: 1

Views: 2884

Answers (2)

Abhijeet Arya
Abhijeet Arya

Reputation: 21

I think you can't do that, but if you want to check if a particular external script is loaded you can check this: Verify External Script Is Loaded

Upvotes: -1

James deBoer
James deBoer

Reputation: 2495

In general, you can't detect when all scripts are finished loading. It is fairly common for a page to wait a couple seconds after the 'onload' event to request an additional round of scripts -- for example, if you want to delay-load ads but don't want to slow down the initial page rendering.

However, extensions do have a flag to run at "document_idle". This flag supposedly makes Chrome wait until the page is "idle" before injected the extension's script. It would not, however wait for a delay-loaded script and it may not even wait for a slow XHR.

More information can be found at http://developer.chrome.com/extensions/content_scripts.html

Upvotes: 2

Related Questions