diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-03 01:29:39 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-03 01:29:39 +0000 |
commit | 5442dafd85700e323fe6c332eeec0f17de6f7891 (patch) | |
tree | 9e065d301222177c4371e0522424deb8f07ba488 /chrome/common/extensions/docs/static/content_scripts.html | |
parent | 40fc8b766191d37dbcbcb67894d233da2899821c (diff) | |
download | chromium_src-5442dafd85700e323fe6c332eeec0f17de6f7891.zip chromium_src-5442dafd85700e323fe6c332eeec0f17de6f7891.tar.gz chromium_src-5442dafd85700e323fe6c332eeec0f17de6f7891.tar.bz2 |
Add new user script injection point "document_idle" and make it the default.
Semantically, document-idle means "when the DOM is ready and layout has been idle for awhile", or more loosely, "as soon as we get around to it".
Right now this uses a simple heuristic. It injects scripts 200ms after DOMContentLoaded, or immediately after onload, whichever happens first.
BUG=26126
TEST=Manual. Extensions with content scripts should work.
Review URL: http://codereview.chromium.org/339064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30784 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/docs/static/content_scripts.html')
-rw-r--r-- | chrome/common/extensions/docs/static/content_scripts.html | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/chrome/common/extensions/docs/static/content_scripts.html b/chrome/common/extensions/docs/static/content_scripts.html index cbd738f..9f1edf1 100644 --- a/chrome/common/extensions/docs/static/content_scripts.html +++ b/chrome/common/extensions/docs/static/content_scripts.html @@ -104,7 +104,24 @@ learn about the <tr> <td>run_at</td> <td>string</td> - <td>Optional. Controls when the files in <code>js</code> are injected. Can be <code>"document_start"</code> or <code>"document_end"</code>. Defaults to <code>"document_end"</code>. In the case of <code>"document_start"</code>, the files are injected after any files from <code>"css"</code>, but before any other DOM is constructed or any other script is run. In the case of <code>"document_end"</code>, the files are injected after the DOM is complete, but before subresources like images and frames have necessarily loaded.</td> + <td>Optional. Controls when the files in <code>js</code> are injected. Can be <code>"document_start"</code>, <code>"document_end"</code>, or <code>"document_idle"</code>. Defaults to <code>"document_idle"</code>. + + <br><br> + + In the case of <code>"document_start"</code>, the files are injected after any files from <code>"css"</code>, but before any other DOM is constructed or any other script is run. + + <br><br> + + In the case of <code>"document_end"</code>, the files are injected immediately after the DOM is complete, but before subresources like images and frames have loaded. + + <br><br> + + In the case of <code>"document_idle"</code>, the browser chooses a time to inject scripts between <code>"document_end"</code> and immediately after the <code><a href="http://www.whatwg.org/specs/web-apps/current-work/#handler-onload">window.onload</a></code> event fires. The exact moment of injection depends on how complex the document is and how long it is taking to load, and is optimized for page load speed. + + <br><br> + + <b>NOTE:</b> In <code>document_idle</code>, content scripts may not necessarily receive the window.onload event, because they may run after it has + already fired. In most cases, listening for the onload event is unnecessary for content scripts running at <code>document_idle</code> because they are guaranteed to run after the DOM is complete. If your script definitely needs to run after <code>window.onload</code> you can check if it has already fired by using the <code><a href="http://www.whatwg.org/specs/web-apps/current-work/#dom-document-readystate">document.readyState</a></code> property.</td> </tr> </table> |