-
Notifications
You must be signed in to change notification settings - Fork 535
Don't rely on invalid media attributes to download? #304
Comments
Looking at the code (briefly-ish), it seems like setting media to "print" would work. |
I think this change seems fine - loadCSS can function the same way using a valid non-matching query like |
That ("print" working) is good news per se. 😃 Unconventional idea: what if we hardcoded Chrome’s loading algorithm to consider "only x" still load-worthy? |
Could I ask, what's the issue leading up to this change? I could see this saving a few requests on some sites, but is it more than that? |
I doubt that would fly. I'm also not sure that loadCSS is the only user-space library doing this. |
I am sure it isn't. This pattern alone is pretty common, without a JS lib:
The drawbacks with that are now pretty far in the past, with link[onload] working more broadly. The onload handlers might be worth searching for, since they might vary less than media usage. There are probably a bunch that set to |
Noted in the other thread, AMP uses a different value for this pattern, also an invalid mq. https://github.com/ampproject/amphtml/blob/878909e3fa568ff2dceea4589579b76e6b624930/src/font-stylesheet-timeout.js#L89-L92 |
Tracked in ampproject/amphtml#22984. |
This came up in the context of CSS loading strategies for dark mode (non-publicized staging link, please don’t share). |
@tomayac fwiw, that post contains an error in the "Finding out if dark mode is supported" section. |
loadCSS is using invlid media attribute values and relies on the fact that browsers currently load them. But loading those resources doesn't make much sense, so we'd love Chrome to stop doing that.
However, that'd create compat concerns with libraries that are relying on that behavior. If loadCSS could stop being one of those libraries, that'd be awesome! :)
The text was updated successfully, but these errors were encountered: