Various websites like GitHub load with flash of unstyled content (FOUC)
Categories
(Core :: Layout, defect, P3)
Tracking
()
People
(Reporter: micah, Unassigned)
References
(Depends on 3 open bugs)
Details
(Keywords: compat, regression, regressionwindow-wanted)
Comment 3•7 years ago
|
||
Updated•7 years ago
|
Comment 5•7 years ago
|
||
Updated•7 years ago
|
Comment 8•7 years ago
|
||
Comment 9•7 years ago
|
||
Comment 10•7 years ago
|
||
Comment 11•7 years ago
|
||
Updated•7 years ago
|
Comment 12•7 years ago
|
||
Comment 14•7 years ago
|
||
Comment 15•7 years ago
|
||
Comment 16•7 years ago
|
||
Reporter | ||
Comment 17•7 years ago
|
||
Comment 18•7 years ago
|
||
Comment 19•7 years ago
|
||
Comment 20•7 years ago
|
||
Comment 21•7 years ago
|
||
Comment 23•7 years ago
|
||
Comment 24•7 years ago
|
||
Comment 25•7 years ago
|
||
Reporter | ||
Comment 26•7 years ago
|
||
Comment 27•7 years ago
|
||
Reporter | ||
Comment 28•7 years ago
|
||
Comment 29•7 years ago
|
||
Comment 31•7 years ago
|
||
Comment 32•7 years ago
|
||
Comment 33•7 years ago
|
||
Comment hidden (offtopic) |
Comment hidden (offtopic) |
Comment 36•7 years ago
|
||
Comment hidden (offtopic) |
Comment hidden (offtopic) |
Comment 39•7 years ago
|
||
Comment 40•7 years ago
|
||
Reporter | ||
Comment 41•7 years ago
|
||
Comment 42•7 years ago
|
||
Reporter | ||
Comment 43•7 years ago
|
||
Comment 44•7 years ago
|
||
Comment 45•7 years ago
|
||
Comment 46•7 years ago
|
||
Comment 47•7 years ago
|
||
Comment 48•7 years ago
|
||
Comment 49•7 years ago
|
||
Comment 50•7 years ago
|
||
Comment 51•7 years ago
|
||
Comment 52•7 years ago
|
||
Comment 53•7 years ago
|
||
Comment 54•7 years ago
|
||
Comment 55•7 years ago
|
||
Comment 56•6 years ago
|
||
Comment 57•6 years ago
|
||
Comment 58•6 years ago
|
||
Comment 59•6 years ago
|
||
Comment 60•6 years ago
|
||
Comment 61•6 years ago
|
||
Comment 62•6 years ago
|
||
Seems to have gotten better for awhile but appears to have worsened in 66.0.2. Either that or I've just been used to it and started noticing it again.
Comment 63•6 years ago
|
||
Can really see it at https://bugzilla.mozilla.org/show_bug.cgi?id=1404468 (on 66.0.3 now).
Rather depressing that Chrome doesn't really have the issue that I can find.
Comment 64•6 years ago
|
||
(In reply to MarkRH from comment #63)
Can really see it at https://bugzilla.mozilla.org/show_bug.cgi?id=1404468 (on 66.0.3 now).
Rather depressing that Chrome doesn't really have the issue that I can find.
Argh, meant to paste: https://forums.warframe.com/topic/1083262-plains-of-eidolon-remaster-hotfix-2471/
(wish this had an edit option sometimes).
Comment 65•5 years ago
|
||
There is still a FOUC on this webpage (for example) : https://fr.libreoffice.org/download/telecharger-libreoffice/
I don't know if there are subframes in it.
Comment 66•5 years ago
|
||
There are not. But what that page does have is:
<script src="themes/libreofficenew/js/modernizr-2.6.2-respond-1.1.0.min.js"></script>
before all of its <link rel="stylesheet">
bits. That script forces rendering to start, because it does all sorts of layout-querying. After that, you will get unstyled content as content is parsed, until the sheets load.
Ideally that script would come after the stylesheet links; that's standard web development advice...
Comment 67•5 years ago
|
||
In particular, that script does:
s.touch = function() {
var c;
return "ontouchstart" in a || a.DocumentTouch && b instanceof DocumentTouch ? c = !0 : y(["@media (", n.join("touch-enabled),("), h, ")", "{#modernizr{top:9px;position:absolute}}"].join(""), function(a) {
c = a.offsetTop === 9
}), c
}
and calls that function, along with all the other detection functions is has.
Comment 68•5 years ago
|
||
After debugging for several hours, I found that if you add a dummy script right after your <body>
tag, FF will only render the page when the CSS is loaded. Sigh.
This will not produce a FOUC: (except for fonts-loading)
<body>
<script>0</script>
...
Comment 69•5 years ago
|
||
FOUC in: https://wiki.mozilla.org/XUL:Lib_XUL
Comment 70•5 years ago
|
||
FOUC in: https://wiki.mozilla.org/XUL:Lib_XUL
Apart from the webfont thing I mention in comment 44, I am not seeing FOUC here. If you are, please file a new bug with steps to reproduce? Chances are, it's due to something an extension is doing....
Comment 71•5 years ago
|
||
Still happens with version 69.0.1 in Windows 10 Pro (updated my Windows 7 system). I was able to get rid of the FOUC on some of my web pages by doing what was mentioned earlier by adding <script>0</script>
after the <body>
tag.
Comment 72•5 years ago
|
||
(In reply to claudio.silva from comment #33)
AdBlocker Ultimate definitely causes FOUC on a lot of websites!
Confirmed — that's definitely what was causing it in my case.
Comment 73•5 years ago
|
||
For my the culprit is the "Saka Key" extension.
Comment 74•5 years ago
|
||
Hi! I am from GItHub's frontend team and we are experimenting with <script defer>
in <head>
right after the <link>
stylesheet tags, and we started to see pretty frequent FOUC in Firefox only, with a clean profile. It is not shipped yet (with FOUC being a blocker) so you can't see this on github.com.
All we did was moving the <script>
tags from end of <body>
to <head>
and adding the defer
attribute to them.
Based on the discussion here it seems like the Firefox team might already know what causes this? Please let us know if we can provide more information. The markup is similar to planet.mozilla.org, where I can also reproduce the FOUC.
Comment 75•5 years ago
|
||
The usual pattern is something like:
- There's no
<script>
in the head blocking the parser and loaded stylesheets. - There's some
<script>
(deferred or doing something async) that queries layout while stylesheets are pending.
I don't know the cause for planet.mozilla.org in particular, but I can check tomorrow on a debugger, as I can reproduce it. If that's not the same thing for GitHub I guess I can ping you and ask for more info :)
Comment 76•5 years ago
|
||
Ah, comment 58 had an analysis of this... So this is "just" https://github.com/whatwg/html/issues/3890, right?
Comment 77•5 years ago
|
||
So the TLDR is that some of your scripts are calling into layout-querying APIs, like offsetTop
, etc...
I guess as a workaround an empty <script></script>
after the stylesheets (or before the <script defer>
s, basically) would prevent the FOUC, by waiting for pending sheets. I think that would effectively emulate the behavior that Blink (Chrome) uses today, which is blocking the parser on stylesheet loads.
Comment 78•5 years ago
|
||
Well, I lie, it needs not to be completely empty, so like: <script>/**/</script>
.
So this would cause a FOUC:
<!DOCTYPE html>
<link rel="stylesheet" href="https://software.hixie.ch/utilities/cgi/test-tools/delayed-file?pause=2&mime=text%2Fcss&text=body+%7B+color%3A+red+%7D">
<script defer src="data:application/javascript,onload = function() {alert('load: ' + getComputedStyle(document.body).color);}; alert('after: ' + getComputedStyle(document.body).color)"></script>
But this would not:
<!DOCTYPE html>
<link rel="stylesheet" href="https://software.hixie.ch/utilities/cgi/test-tools/delayed-file?pause=2&mime=text%2Fcss&text=body+%7B+color%3A+red+%7D">
<script>/**/</script>
<script defer src="data:application/javascript,onload = function() {alert('load: ' + getComputedStyle(document.body).color);}; alert('after: ' + getComputedStyle(document.body).color)"></script>
Comment 79•5 years ago
|
||
Disclaimer: I know the above is quite a decent hack... I've been looking into FOUC-related bugs like bug 687441 recently...
Looks like there's spec agreement on the issue in comment 76 so maybe we should just change defer
scripts to do that automatically before executing them...
Comment 80•5 years ago
|
||
Still happens in 75.0 Mac OS both High Sierra (10.13.6) and Catalina (10.15.4). I created a sample page that, at least on my pc, exhibits the FOUC when the Developer Tools are opened (cache disabled, no throttling). The test page simply has a stylesheet loaded with some delay (6s).
- This page: this page has FOUC
- This page: this page doesn't show FOUC (it employs the empty script tag hack described before in this discussion).
Both the links work perfectly both on Safari and Chrome - even with Developer Tools opened (and cache disabled, as always).
Surprisingly, the same issue doesn't show up (at least, on my pc) if I manually erase the Web cache (from the preferences menu). Might it be somehow related to the developer tools?
Comment 81•5 years ago
|
||
(In reply to Stefano Cappellini from comment #80)
Might it be somehow related to the developer tools?
Yes, that's an issue with the devtools inspector. They update the layout of the page so that you can well, inspect stuff with the current styles. Firefox doesn't block the parser so there is actually content in the page. If you use the script hack the parser is blocked until the stylesheet comes back so the same happen, but the page is empty instead.
I'd file an inspector bug so that the devtools developers can consider changing it.
Comment 83•3 years ago
|
||
This still happens in Windows 11 Pro 21H2, on Firefox Release 100.0 64-bit (May 3, 2022).
Comment 84•2 years ago
|
||
using Firefox 100.0.2 64bit on Ubuntu. I have the impression that flashing unstyled content has massively increased in FF 99 or 100, with even twice switching i.e. unstyled-styled-unstyled-styled during page rendering. It's really annoying. I use add-on NoScript 11.4.5 so it may also be related to that, but with the Web in its current state I am reluctant to disable this extension.
Updated•2 years ago
|
Comment 85•2 years ago
|
||
The severity field for this bug is relatively low, S3. However, the bug has 10 votes.
:dholbert, could you consider increasing the bug severity?
For more information, please visit auto_nag documentation.
Comment 86•2 years ago
|
||
The last needinfo from me was triggered in error by recent activity on the bug. I'm clearing the needinfo since this is a very old bug and I don't know if it's still relevant.
Comment 87•1 year ago
|
||
[Tracking Requested - why for this release]:
Updated•1 year ago
|
Description
•