When is run_at: document_idle content script executed?

There are three options for running content scripts:

  • document_start - entered at the beginning of <head>
  • document_end - entered immediately after DOMContentLoaded
  • document_idle - entered when ???
+2
source share
1 answer

According to the current source of chromium :

We are trying to start downtime in two places: here and DidFinishLoad. DidFinishDocumentLoad () corresponds to the completion of the loading of the document, whereas DidFinishLoad corresponds to the completion of the document and the total loading of sub-resources. We do not want to delay the script injection for a particularly slow subresource, so we postponed the pending task from here, but if we finish everything to this point (i.e. DidFinishLoad () fires), then there is no reason to wait.

Translated to a web developer, it basically means ...

document_idle scripts will run, the earliest of these things is true:

  • window.onload fired
  • It has been 200 ms since DOMContentLoaded running.

On typical pages, these scripts are likely to run on # 2.

+7
source

Source: https://habr.com/ru/post/1266365/


All Articles