-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async css #3983
Comments
While the JS-based packaging does not have an issue with loading CSS on demand of JS module( lazy or in run time), IMO having coherent phased load behavior over all resources including script, images, fonts, css, etc has sense to be unified and be a part of HTML standard. So I would extend this feature request to "unify the load behavior for web page resources" instead of just CSS lazy load. Also current separation of synchronous/async/delayed behavior does not reflect the need for modern web app. In complex apps the order of load is phased and each phase accounts dependency graph. Extending loading parameters with "depend on" and "load order" is a good addition to proposal. All seems to be easy polyfilled for backward compatibility. |
There are two related but orthogonal issues here:
As an example of why they are orthogonal, consider that it currently seems, that marking a script "async" will give it the lowest priority. But even though a script might not be needed for the first render, it might be desirable to have it load before, say, large decorative images on the page. This issue is about (1) for the stylesheet resource type. |
Perhaps we can add a semantic that |
Maybe we can revive this issue? Async CSS is pretty essential. It's the reason libraries like Font Awesome have to resort to <link rel="stylesheet" href="/path/to/my.css" media="print" onload="this.media='all'"> |
Allow css files to be marked as async meaning that they will not block rendering. The syntax could be a new attribute on the link element or a new value for "rel" attribute (that already have link types such as "dns-prefetch", "preconnect", "prefetch", and "preload" that also seems to serve a technical, how-to-load purpose), say "
<link rel='stylesheet async' type='text/css' href='theme.css'>
".This functionality is similar to the async attribute on the script element, and the font-display descriptor for the @font-face CSS at-rule.
A web search will find quite a few articles about how to do this in a more or less hackish way, so there seems to be a demand for it. It seems that the browsers could rather easily add this in a much more reliable way as the browser e.g. knows if the resource is already in the cache and can control the priority of requests.
(I did read the contributing guidelines, but as I read them, they only talk about submitting pull requests and not about submitting issues)
The text was updated successfully, but these errors were encountered: