tl;dr: We should offer a simple solution for async loading stylesheets at a low-priority. Something in the vein of <link async>
or <link importance="low">
.
The Filament Group recently posted a pattern for loading CSS asynchronously, leveraging a workaround setting a link
's media
attribute to print
:
<link rel="stylesheet" href="/path/to/my.css" media="print" onload="this.media='all'">
Although link[rel=preload]
exists for achieving a similar pattern (toggle rel
once loaded vs media
), it fetches files early at a higher perceived priority. This can have the downside of de-prioritizing other critical requests.
An alternative to the print
pattern above would be standardizing on a way to async load stylesheets with a low-priority. This could be achieved in a few ways:
- Explore
<link rel="stylesheet" href="/path/to/my.css" async>
- Modify the behavior of Priority Hints such that
<link rel="stylesheet" href="/path/to/my.css" importance="low">
both signaled low-network priority and that the link should be non-render blocking
Starting this discussion to explore whether this is overall problem is a pattern we would like to better solve in the web platform and if so, what the shape of a solution should be.