09:12
<Schalk Neethling>

Question for you all. Has it been considered to add some or all of the attributes related to loading behavior to the link element when rel=stylesheet? This kinda ties into my question concerning last week concerning the disabled attribute. I made a video and this started some discussions on LinkedIn and this idea was floated. For example:

<link rel=stylesheets href="./css/lowprio.css" media="screen" loading=lazy>

or

<link rel=stylesheets href="./css/lowprio.css" media="screen" defer>

or

<link rel=stylesheets href="./css/lowprio.css" media="screen" fetchpriority="low">

Of course not all of these, but the one or one's that would make most sense for CSS.

09:19
<emilio>

Defer you can get with something like media="not all" onload="this.media = 'screen'" (but not great that it needs js).

It's not clear what loading=lazy would do?

09:20
<Schalk Neethling>
Yeah, the media "hacks" was mentioned to kinda force a low priority load. loading-lazy was a bad example and one that would not make sense with CSS - I was more thinking something like fetchpriority would be more interesting.
09:21
<annevk>
zcorpan: I'm not a big fan of the kind of diffs no wrapping at all results in. While we have HTML diffs, the source diffs are important too.
09:21
<Schalk Neethling>
so fetchpriority and defer. The thing with disabled (other than not consistent support across browsers) is that most people would like to be able to have the CSS load, but without blocking and low priority.
09:23
<Domenic>
I find the no-wrapping diffs just as good personally. (I use no-wrapping on non-WHATWG specs.) In both WHATWG and non-WHATWG specs the diff basically ends up being "this paragraph or step changed".
09:24
<Domenic>
Rarely, in WHATWG specs, the diff can be "this one line in the paragraph or step changed", if the change is adding around the same number of characters as are removed. But usually it's the whole step or paragraph that need rewrapping.
09:24
<Schalk Neethling>
There is also currently https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/blocking for script
09:24
<Domenic>
And diff viewers are pretty good at highlighting word diffs within paragraph diffs anyway.
09:24
<annevk>
Yeah, it's true that having to re-wrap often makes it hard anyway. And when GitHub's within-a-line-changes feature works, it's all good. But that isn't always.
09:25
<Schalk Neethling>
That is probably less interesting.
09:25
<Schalk Neethling>
Perhaps the inverse for CSS :) Now I am just thinking out loud.
09:26
<Schalk Neethling>
Thanks, Emilio
09:30
<emilio>
Fetchpriority does exist and does affect the network fetch priority of stylesheets afaict
09:34
<emilio>
What about disabled is inconsistent across browsers? We had to add it for compat, but current behavior is deliberate, see https://github.com/whatwg/html/issues/3840
09:48
<Schalk Neethling>
emilio: see here https://matrix.to/#/!AGetWbsMpFPdSgUrbs:matrix.org/$N8dOVAIGxATxE2SwGrHTW4jQk2bVEpAp2yfh0LwpUWE
09:49
<Schalk Neethling>

Fetchpriority does exist and does affect the network fetch priority of stylesheets afaict

Nice!

09:51
<Schalk Neethling>
Also, this reply from Noam Rosenthal referring to the Chromium issue - https://matrix.to/#/!AGetWbsMpFPdSgUrbs:matrix.org/$MKLUkD7OnrKnDuOfT9J7UgRPCiVRcxT-TGHn5u2W2p0
09:51
<Schalk Neethling>
There is also a thread from that one that includes a link to the Bugzilla ticket for Firefox
09:55
<Schalk Neethling>

tl;dr

Firefox

  • makes a fetch request on load
  • does not apply the CSS
  • when the disabled flag is flipped
  • applies the stylesheet and loads any assets referenced in the CSS

Chromium

  • makes a fetch request on load
  • does not apply the CSS
  • when the disabled flag is flipped
  • seems to make another fetch request for the CSS but most likely gets this from cache
  • applies the stylesheet and loads any assets referenced in the CSS

Safari

  • no fetch request on load
  • when the disabled flag is flipped
  • loads the CSS and any assets referenced in the CSS
  • applies the stylesheet
10:03
<emilio>
I see, so it seems like we speculatively load it regardless of the disabled attribute but other than that the observable behavior from the page should be the same in all browsers?
10:04
<Schalk Neethling>
Indeed
10:04
<Schalk Neethling>
Once you flip the bit, they all behave the same.
10:05
<Schalk Neethling>
Apply and load any additional referenced assets.
10:10
<emilio>
Right, so I agree that that seems like a bug in chromium and Firefox (no need to speculatively load a disabled sheet)
10:13
<emilio>
https://bugzilla.mozilla.org/show_bug.cgi?id=1376729 is definitely not the right ticket tho, we do support the attribute
10:13
<emilio>
Will file
10:20
<Schalk Neethling>
Agreed.
10:23
<emilio>
https://bugzilla.mozilla.org/show_bug.cgi?id=1987372
10:25
<Schalk Neethling>
Aha! I see fetchPriority is documented individually for each type of element it applies to. Here is the one for the link element - https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/fetchPriority 🙌
10:48
<zcorpan>
annevk: 100-col breaks I think is more annoying both for diffs and maintenance. Semantic breaks still has mental overhead to think about and fiddle with linebreaks. On balance I think I like no-breaks best
11:26
<annevk>
zcorpan: I guess I'm okay with slowly switching towards that. If we want to reformat a complete file I'd like to see the impact on blame first in some kind of demo repo.
11:40
<Domenic>
Hmm I don't like the slow switch myself, would prefer all at once. But my opinion should be carrying less and less weight these days, so 🤷
11:42
<annevk>
There might be some way to do all at once and have it minimally impact blame. I think Gecko did something like that when it added auto formatting. Just need to actively consider that as making blame bad is a problem.
12:38
<jmdyck>
Maybe git blame --ignore-rev <rev>
12:42
<jmdyck>
(and related machinery)
12:50
<jmdyck>
Apparently github's 'Blame' button respects a repo's .git-blame-ignore-revs file: https://docs.github.com/en/repositories/working-with-files/using-files/viewing-and-understanding-files#ignore-commits-in-the-blame-view
14:51
<AtkinsSJ>
I don't think it's already been mentioned, but wrapping does make it harder to grep for a specific phrase.
15:27
<annevk>
jmdyck: yeah, I guess what I'm wondering about is how ignore-revs works, but I can look that up later
18:03
<zcorpan>
I created https://github.com/zcorpan/reformahtml which now seems to work reasonably for whatwg/html. Can use data-noreformat to intentionally use custom indentation.
18:49
<Schalk Neethling>

I also noticed that fetchpriority is a hint and not an instruction so it is up to the browser to determine whether to actually lower the priority.

I also see that we do have blocking on link rel=stylesheet but, this is to intentionally instruct the browser to render block which, according the the docs on MDN, is mostly useful if the stylesheet was injected with JavaScript as stylesheets linked in the head of the document will already be render blocking by default.

So, perhaps what is "missing" for rel=stylesheet is a defer that is an instruction and not a hint.

We then have disabled, which is a HARD do-not-load until I say so :)

defer, which is an explicit instruction to the browser to load the stylesheet with a lower priority (lowest??)

fetchpriority - which is a hint that the browser can choose to ignore if it determines there to be little or no benefit to fetching the external resource with a lower priority that the other stylesheets.

Thoughts?

20:20
<zcorpan>
Draft PR https://github.com/whatwg/html/pull/11640
20:30
<Abed12345>
ماقدرت أسوي شيء