什么时候run_at:document_idle内容脚本运行? [英] When does a run_at: document_idle content script run?
问题描述
运行内容脚本有三种选择:
-
document_start
- 注入在< head>
-
document_end
开头 - 在> DOMContentLoaded
之后 -
document_idle
我们尝试在两处闲置:Here和DidFinishLoad。
DidFinishDocumentLoad()对应于完成文档的加载,
,而DidFinishLoad对应于完成文档和所有
子资源的加载。我们不想为
特别慢的子资源阻止脚本注入,所以我们从这里设置了延迟任务 - 但是如果
我们在该点之前完成了所有操作(即,DidFinishLoad()是
$引发),那么就没有理由继续等待。
转换成web开发人员说这基本上意味着...
document_idle
脚本将会运行最早的这些事情之一:
-
window.onload
已被触发 - 自< c $ c> DOMContentLoaded 已被解雇。
在典型页面上,这些脚本可能会在#2 。
There are three options for running content scripts:
document_start
- injected at the start of the<head>
document_end
- injected right afterDOMContentLoaded
document_idle
- injected when???
According to the current Chromium source:
We try to run idle in two places: here and DidFinishLoad. DidFinishDocumentLoad() corresponds to completing the document's load, whereas DidFinishLoad corresponds to completing the document and all subresources' load. We don't want to hold up script injection for a particularly slow subresource, so we set a delayed task from here - but if we finish everything before that point (i.e., DidFinishLoad() is triggered), then there's no reason to keep waiting.
Translated into web developer speak that basically means…
document_idle
scripts will run the earliest one of these things is true:
window.onload
has fired- It's been 200ms since
DOMContentLoaded
has fired.
On typical pages, these scripts will likely run at #2.
这篇关于什么时候run_at:document_idle内容脚本运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!