Note: With "document_idle", content scripts may not necessarily receive the window.onload event, because they may run after it hasĪlready fired. 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. In the case of "document_idle", the browser chooses a time to inject scripts between "document_end" and immediately after the window.onload event fires. In the case of "document_end", the files are injected immediately after the DOM is complete, but before subresources like images and frames have loaded. In the case of "document_start", the files are injected after any files from css, but before any other DOM is constructed or any other script is run. Can be "document_start", "document_end", or "document_idle". These are injected in the order they appear in this array.Ĭontrols when the files in js are injected. The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array, before any DOM is constructed or displayed for the page. The list of CSS files to be injected into matching pages.
If you want to inject the code only sometimes,Īn extension can insert multiple content scripts into a page Įach of these content scripts can have multiple JavaScript and CSS files.Ĭontrols the pages this content script will be injected into.įor more details on the syntax of these strings. If your content script's code should always be injected, These limitations aren't as bad as they sound.Ĭontent scripts can indirectly use the chrome.* APIs,įor more insight into what content scripts can and can't do, Use variables or functions defined by web pages or by other content scripts Use variables or functions defined by their extension's pages However, content scripts have some limitations.