Hi all,
TLDR: We are experimenting with prerendering links which open in a new tab. These prerendered pages will be visible in some extension APIs and you may need to update your extension to handle this.
What's changing
Starting in Chrome M135, we have initiated the origin trial of target_hint field of speculation rules (explainer). The developers can specify `target_hint` field as follows to prerender a page into new tab:
```
<a href="/prerendering.html" target="_blank">Example link</a>
<script type="speculationrules">
{
"prerender": [
{
"source": "list",
"urls": ["prerendering.html"],
"target_hint": "_blank"
}
]
}
</script>
```
This feature will only be present on sites which have opted in to the origin trial, and links will only be prerendered if the site has specifically opted in for a given URL as shown above. However, we expect adoption to increase over time, so you should prepare regardless.
How this impacts extensions
In some situations (e.g `chrome.webNavigation` and `chrome.webRequest` events) prerendered pages will be exposed with a `windowId` of WINDOW_ID_NONE and the appropriate `documentLifecycle` value. You may want to check for these values and ignore those events, or handle them differently.
Prerendered tabs are not exposed in the `chrome.tabs.query()` API, but are returned from `chrome.tabs.get()` if the tab ID is provided along with the window ID of `WINDOW_ID_NONE`.
This behavior change is mentioned in the WebExtensions Community Group: https://github.com/w3c/webextensions/pull/537
https://developer.chrome.com/blog/extension-news-april-2024#other_api_launches
How you can test any changes
To force enable flag for testing:
Enable chrome://flags/#enable-experimental-web-platform-features, and restart chromium.
Testing demo site: https://prerender2-specrules.glitch.me/
After step 1, speculation rules have been added, and it is possible to see the speculation rules in DevTools. Upon step 2 (link click), the page is shown in a new tab and the speculation rules will be activated successfully so the page navigation is faster than a normal navigation. It is also possible to check whether the page is prerendered by checking `document.prerendering === true` in the page.
How to check the status : DevTools > Application Tab > Speculation loads > Speculation
To track the current progress of implementation: [Public] DevTools: (Un)implemented features for prerender-into-new-tab
For older version (before M137), the target_hint field is not shown in DevTools.
For version after M137, target_hint field is available in DevTools.