The W3C TAG, on which I serve, recently published a (draft at time of this writing) finding about the issue of distributed content, calling out systems like AMP, Facebook instant articles, and Apple News as potentially problematic. It includes a suggestion to allow documents to be hosted and served on their original origin, but still be rendered as fast as AMP:
Where the motivation for embedding is to improve performance, an alternative is to support the limited pre-rendering of a document prior to navigation. Past efforts at this have included `` but this proved difficult to do without side effects. A more modest approach, supported by constraints that could be enforced by Feature Policy, may be a practical option.
I’d like to set out an idea for how this could work and get feedback.
Currently, one can do <link rel='prerender' ... />
and prompt the browser to preload and render a page prior to the user declaring an intent to visit it. However, this already has poor browser support and Chrome is dropping support in v58. The challenges associated with prerender turn out to be significant: a page fully loaded in a background tab might trigger an interactive permission prompt, start playing audio, use significant CPU or memory, etc.
Google’s AMP project was designed to solve some of these problems by creating a content format that guaranteed certain things about the performance of the content. However, in order to pre-render AMP content, the AMP viewer uses IFRAMEs and therefore hijacks the origin of the URL. The viewer is also constrained to only work with AMP, rather than equally fast or even faster performing content that is not AMP compliant, and of course leaves content creators with severe restrictions on what they can feasibly offer readers.
The new proposed Feature Policy introduces the ability for content creators to opt into constraints on the behaviour of their page in an HTTP header. I propose that we add more feature names to this, to cover all the items that generate perf or pre-rendering concerns, and reintroduce <link rel='prerender'>
on the basis that the UA can now enforce feature-policy-driven minimum criteria to qualify for prerendering. This could include feature directives like:
- Enhanced user interaction required: Playing media, triggering permission prompts, interacting with client side storage APIs, sending HTTP requests from script, and updating DOM from script require user interaction (same as we do already for opening popup windows). Browser can deny attempts to do this stuff without user interaction
- Static layout: The layout of the page can be calculated in a single pass. If objects change size (eg images without width and height load in) the browser may stop rendering and throw an error.
- Load on demand: The page does not need to load subresources until they are needed, so the browser can choose to trigger media downloading only when the images are in view.
These might end up being a larger number of more granular feature names, but you get the idea. Those wanting to create an AMP-like solution could invite content creators to publish pages conforming to the required feature policy, and if they complied, those pages could be prerendered and navigation could be instant.
What do you think?