Skip to content
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

stop FOUC #326

Closed
stevefaulkner opened this issue Jul 17, 2014 · 8 comments
Closed

stop FOUC #326

stevefaulkner opened this issue Jul 17, 2014 · 8 comments
Milestone

Comments

@stevefaulkner
Copy link

when respec loads doc often there is a flash of unstyled content, would be nice if it did not occur

@marcoscaceres
Copy link
Member

So, there are a number of challenges:

  1. The script tag that loads ReSpec is generally set to run async - this can only be fixed by Editors.
  2. the style module runs at the turn of the event loop and hence after first paint.
  3. Even when the async attr is removed from the script tag, 2 still occurs (this might be the fault of require.js, but I'm not sure).

My solution would be to only use the style module if document is running async. Otherwise, add the following to profile-w3c-common.js - using a MutationObserver, it watches for when the respecConfig is added to the document - then figures out which style to use based on the respecConfig, and immediately adds it to the head of the document. It, of course, requires that the script be running sync:

var sync = (document.currentScript && !document.currentScript.async) || false;
if(sync){ 
    //if we have mutation observer support
    if (window.MutationObserver && !window.respecConfig) {
        var observer = new MutationObserver(function(mutation) {
            if (window.respecConfig) {
                observer.disconnect();
                addStyle(window.respecConfig);
            }
        });
        observer.observe(document.head, {
            childList: true
        });
    } else if (window.respecConfig) {
        addStyle(window.respecConfig);
    }
}
//add the style - basically the same as w3c/style module
function addStyle(conf) {
   ...
}

The other option is for Editors to just include a link element to TR/base css or to the style sheet for their spec.

@halindrome
Copy link
Contributor

Since for some documents the initial load can take a very long time, I
would almost rather have the option of a 'loading' throbber that would
appear so that as all the churn happens people are not attempting to
navigate the document. It is very frustrating to have the document shift
around while scrolling.

On Sat, Jul 26, 2014 at 11:59 PM, Marcos Caceres notifications@github.com
wrote:

So, there are a number of challenges:

  1. The script tag that loads ReSpec is generally set to run async -
    this can only be fixed by Editors.
  2. the style module runs at the turn of the event loop and hence after
    first paint.
  3. Even when the async attr is removed from the script tag, 2 still
    occurs (this might be the fault of require.js, but I'm not sure).

My solution would be to only use the style module if document is running
async. Otherwise, add the following to profile-w3c-common.js - using a
MutationObserver, it watches for when the respecConfig is added to the
document - then figures out which style to use based on the respecConfig,
and immediately adds it to the head of the document. It, of course,
requires that the script be running sync:

var sync = (document.currentScript && !document.currentScript.async) || false;if(sync){
//if we have mutation observer support
if (window.MutationObserver && !window.respecConfig) {
var observer = new MutationObserver(function(mutation) {
if (window.respecConfig) {
observer.disconnect();
addStyle(window.respecConfig);
}
});
observer.observe(document.head, {
childList: true
});
} else if (window.respecConfig) {
addStyle(window.respecConfig);
}}//add the style - basically the same as w3c/style modulefunction addStyle(conf) {
...}

The other option is for Editors to just include a link element to TR/base
css or to the style sheet for their spec.


Reply to this email directly or view it on GitHub
https://github.com/darobin/respec/issues/326#issuecomment-50256002.

Shane McCarron
halindrome@gmail.com

@marcoscaceres
Copy link
Member

I think that's a related but different problem. Ideally, we just want to
fix that FOUCking problem (hehe, sorry not sorry) :) even with a loading
indicator, you would still have the flash as Respec is coded today. Need to
look a bit more at what the DOMReady script is doing.

On Sunday, July 27, 2014, Shane McCarron notifications@github.com wrote:

Since for some documents the initial load can take a very long time, I
would almost rather have the option of a 'loading' throbber that would
appear so that as all the churn happens people are not attempting to
navigate the document. It is very frustrating to have the document shift
around while scrolling.

On Sat, Jul 26, 2014 at 11:59 PM, Marcos Caceres <notifications@github.com
javascript:_e(%7B%7D,'cvml','notifications@github.com');>
wrote:

So, there are a number of challenges:

  1. The script tag that loads ReSpec is generally set to run async -
    this can only be fixed by Editors.
  2. the style module runs at the turn of the event loop and hence after
    first paint.
  3. Even when the async attr is removed from the script tag, 2 still
    occurs (this might be the fault of require.js, but I'm not sure).

My solution would be to only use the style module if document is running
async. Otherwise, add the following to profile-w3c-common.js - using a
MutationObserver, it watches for when the respecConfig is added to the
document - then figures out which style to use based on the
respecConfig,
and immediately adds it to the head of the document. It, of course,
requires that the script be running sync:

var sync = (document.currentScript && !document.currentScript.async) ||
false;if(sync){
//if we have mutation observer support
if (window.MutationObserver && !window.respecConfig) {
var observer = new MutationObserver(function(mutation) {
if (window.respecConfig) {
observer.disconnect();
addStyle(window.respecConfig);
}
});
observer.observe(document.head, {
childList: true
});
} else if (window.respecConfig) {
addStyle(window.respecConfig);
}}//add the style - basically the same as w3c/style modulefunction
addStyle(conf) {
...}

The other option is for Editors to just include a link element to
TR/base
css or to the style sheet for their spec.


Reply to this email directly or view it on GitHub
https://github.com/darobin/respec/issues/326#issuecomment-50256002.

Shane McCarron
halindrome@gmail.com
javascript:_e(%7B%7D,'cvml','halindrome@gmail.com');


Reply to this email directly or view it on GitHub
https://github.com/darobin/respec/issues/326#issuecomment-50277145.

@darobin darobin modified the milestone: v4 Dec 23, 2014
@marcoscaceres marcoscaceres modified the milestones: 3.3, v4 Apr 28, 2016
marcoscaceres pushed a commit that referenced this issue May 23, 2016
Fix(style): reduce ReSpec FOUC (relates to #326)
marcoscaceres added a commit that referenced this issue May 23, 2016
* 'develop' of github.com:w3c/respec:
  Fix(SpecHelper): remove isPhantom() dead code
  Feat(utils): map/reduce linkCSS() instead of jQuery
  Fix (SpecHelper): reduce dependece on jQuery
  Fix(style): reduce ReSpec FOUC (relates to #326)
marcoscaceres added a commit that referenced this issue May 23, 2016
* develop:
  v3.2.124
  Fix(ui): close ui when doc is clicked (closes #772)
  Fix(base-runner): improve error reporting
  Fix(markdown): use Array.from instead of for/of loop
  Fix(headers-spec): should query doc, not document
  Fix(markdown-spec): should query doc, not document
  Feat(markdown): disable md linking via 'nolinks' class (closes #777)
  Chore(travis): Bump node version to 6.2
  Chore(appveyor): Bump node version to 6.2
  Feat(save-html): beautify HTML/XML output (closes #750)
  Feat(hightlight): use new highlighter (#767)
  Fix(SpecHelper): remove isPhantom() dead code
  Feat(utils): map/reduce linkCSS() instead of jQuery
  Fix (SpecHelper): reduce dependece on jQuery
  Fix(style): reduce ReSpec FOUC (relates to #326)
  Feat(utils): add makeOwnerSwapper() (#766)
  Fix(beautify-options): disable wrap_line_length, as it gets confused
@marcoscaceres
Copy link
Member

Note to future @marcoscaceres: if you combine all the styles into a single element, and insert it into the document on end-all, that will reduce the number of style recalculations significantly. Also, you should not insert styles that are not needed (e.g., if there is not WebIDL in the spec, then don't include the WebIDL styles... dummy). If we can move more stuff to base.css, then that is also a huge win.

@halindrome
Copy link
Contributor

FWIW if there are easy ways to just rely on what is ALREADY in base.css that would be a huge win too. In that we would have more consistency within and among specs. Right @fantasai ?

@marcoscaceres
Copy link
Member

On 27 Jun 2016, at 10:10 PM, Shane McCarron notifications@github.com wrote:

FWIW if there are easy ways to just rely on what is ALREADY in base.css that would be a huge win too. In that we would have more consistency within and among specs. Right @fantasai ?

We need to actually dig into ReSpec's style sheet and see what duplication there is. Base.css is unlikely to ever give us good syntax highlighting tho because we (ReSpec and BS) depend on different tools... But who knows.

Maybe we can get consistent notes, warnings, tables, etc. Those are the low hanging fruits.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

marcoscaceres added a commit that referenced this issue Feb 13, 2017
marcoscaceres added a commit that referenced this issue Feb 13, 2017
* develop:
  v10.1.4
  fix: Reduce FOUC (closes #326)
marcoscaceres added a commit that referenced this issue Feb 13, 2017
marcoscaceres added a commit that referenced this issue Feb 13, 2017
* develop:
  v10.1.5
  Revert "fix: Reduce FOUC (closes #326)"
@fantasai
Copy link

base.css intentionally doesn't include syntax highlighting rules. Definitely should be relying on it for styling tables, etc. -- anything documented in http://fantasai.inkedblade.net/style/design/w3c-restyle/2016/sample really.

@marcoscaceres
Copy link
Member

@fantasai, unrelated... but tables are still super broken :(

screenshot 2017-02-14 16 00 57

marcoscaceres added a commit that referenced this issue Feb 14, 2017
marcoscaceres added a commit that referenced this issue Feb 14, 2017
* develop:
  v10.1.6
  chore(package): update dependencies
  fix: Reduce FOUC (closes #326)
shikhar-scs pushed a commit to shikhar-scs/respec that referenced this issue Feb 19, 2018
Adds support for two markers in close proximity.
shikhar-scs pushed a commit to shikhar-scs/respec that referenced this issue Feb 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants