W3C home > Mailing lists > Public > public-css-archive@w3.org > October 2019

Re: [csswg-drafts] [selectors] Add :before-load() pseudo-class (#4462)

From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
Date: Mon, 28 Oct 2019 19:06:30 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-547100184-1572289589-sysbot+gh@w3.org>
As a high-level critique: this doesn't belong on a pseudo-class, as it isn't something that'll vary by element. It belongs in a MQ, like `(page-state: loading)` or something.

----

I'd have to go archive-diving, but I'm pretty sure we've discussed something like this in the past. I think there were two big strikes against it:

* You've already alluded to this, that there are several notions of "loading" that might be relevant, and it's kinda difficult to refer to them without weird terminology or being overly specific. And some notions of loading are page-specific, like "wait for this fetch to complete before showing this element".
* JS already has all the knowledge necessary to handle this itself, since it can respond to the relevant events and can add/remove classes from the root element accordingly.

Like you said tho, it is true that JS cannot *both* (a) have things invisible immediately on page load, and (b) fail-open by having them become visible if JS is blocked or errors. That would be a decent argument for providing this functionality in a MQ, with examples and warning text telling you how to use it "safely". (Which I suspect would be more natural anyway, as hiding things feels like an "exception" and thus is more natural to segregate away inside a MQ block, rather than hiding by default and putting your normal styles there.)

-----

A big question is thus, what loading transitions would we want to care about? Almost certainly the 'DOMContentLoaded' event, and maybe the 'load' event; anything else?  The benefit of those two is that it maps cleanly to the `document.readyState` enum; a page starts in "loading", goes to "interactive" when `DOMContentLoaded` fires, and goes to "complete" when `load` fires.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4462#issuecomment-547100184 using your GitHub account
Received on Monday, 28 October 2019 19:06:32 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:55 UTC