Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

FOUC on SSR #38

Closed
2 tasks done
ghost opened this issue Jul 24, 2017 · 19 comments
Closed
2 tasks done

FOUC on SSR #38

ghost opened this issue Jul 24, 2017 · 19 comments
Assignees

Comments

@ghost
Copy link

ghost commented Jul 24, 2017

I'm submitting a ...

  • bug report
  • feature request

Feature Request:

Bug Report:

Edit: Seems some imported libraries will cause FOUC of auth components.

@ghost ghost closed this as completed Jul 24, 2017
@ghost ghost changed the title Import BlueprintJS causes FOUC of login component Large components at Router level cause FOUC of login component Jul 24, 2017
@ghost ghost reopened this Jul 24, 2017
@ghost ghost closed this as completed Jul 24, 2017
@ghost ghost changed the title Large components at Router level cause FOUC of login component Some imported libraries cause FOUC of login component before loading Jul 24, 2017
@Metnew
Copy link
Owner

Metnew commented Jul 24, 2017

in development or in production with SSR?

@ghost
Copy link
Author

ghost commented Jul 24, 2017

Heh, SSR. I've found it on shift refresh. Only need to import big libraries and eventually it'll happen. I get the screen below for about 1.4 seconds of loading on shift refresh and first time loading. Sorry for the bad quality, chrome frame inspector. The login component doesn't show up (error in my routes), just the screen below.
chrome

SSR. Got it to happen on clone. Importing big packages (just need import statement). Using the performance tool in chrome and screen frames.

@ghost ghost reopened this Jul 24, 2017
@ghost ghost changed the title Some imported libraries cause FOUC of login component before loading Larger imported libraries cause FOUC before loading Jul 24, 2017
@ghost ghost closed this as completed Jul 24, 2017
@ghost
Copy link
Author

ghost commented Jul 24, 2017

At entry point of 2.3MB (of course it's gzipd'), on normal page refresh I'll get about 200MS of the above :( It's the FOUC of the login component (I had it disabled).
image

@Metnew
Copy link
Owner

Metnew commented Jul 25, 2017

@TheDolo , I found error in SSR, but can't push fix for it right now, would be fixed soon (approximately: one day)

@Metnew Metnew reopened this Jul 25, 2017
@Metnew Metnew added the bug label Jul 25, 2017
@Metnew
Copy link
Owner

Metnew commented Aug 5, 2017

@TheDolo SSR was rewritten, should be fixed now

@Metnew Metnew closed this as completed Aug 5, 2017
@ghost
Copy link
Author

ghost commented Aug 5, 2017

image

If you shift refresh on your demo, you'll find that! Auth FOUC will be there too if not logged in. (Not the end of the world, but more libs pronounces this).

@Metnew Metnew reopened this Aug 5, 2017
@Metnew
Copy link
Owner

Metnew commented Aug 5, 2017

@TheDolo FOUC caused by Semantic.UI. SUI styles ~540KB - before they are downloaded only styled-components styles are active. I'm trying to follow Shell pattern, but not sure is it so easily possible.
Approximate improvements plan:

  1. vendor.css and vendor.js must be separated into smaller files. Separate each file into 2 smaller chunks and download would be faster
  2. Critical CSS path must be extracted from SUI.

Proof:
2017-08-06 01 28 08

UPD: Probably, I need to say that this behaviour likely to occurs only on a first load = Before the app will be cached by ServiceWorkers.

The main reason of FOUC - server can't render SUI styles.

@Metnew Metnew changed the title Larger imported libraries cause FOUC before loading SUI bundled styles forces FOUC in SSR Aug 5, 2017
@Metnew Metnew changed the title SUI bundled styles forces FOUC in SSR FOUC on SSR Aug 5, 2017
@ghost
Copy link
Author

ghost commented Aug 5, 2017

Wonderful, thank you for the explanation!

@Metnew Metnew self-assigned this Aug 6, 2017
@Metnew
Copy link
Owner

Metnew commented Aug 8, 2017

@TheDolo probably problem would be solved after #49 will be solved. There wouldn't be unnecessary re-rendering. But still, FOUC might be because of the huge SUI bundle. Also, I'm currently experimenting with separation of SUI bundle for faster content download with HTTP2.

@Metnew Metnew removed the bug label Aug 8, 2017
@Metnew
Copy link
Owner

Metnew commented Aug 9, 2017

@TheDolo do you still get FOUC on page loading?

@ghost
Copy link
Author

ghost commented Aug 9, 2017

I'll have to refactor your current updates in, I'm a few days behind your commits. I can't get your demo to show it, so thats good. Will follow up in a day or two. Still having problems with every page refresh going back to auth page since your new refactor only in SSR + using my own endpoints for auth. It worked before your refactor and my endpoints have not changed, so I'm assuming it's something with the auth wrapper. But I don't see any FOUC when shift refresh even if it takes me back to auth!

@Metnew
Copy link
Owner

Metnew commented Aug 9, 2017

Shifting to /auth was caused by invalid configuration provided to OfflinePlugin, so right now it's fixed.
Also, I recommend you to check dev branch due to new features:

  1. Webpack_config was rewritten in es6
  2. Webpack configuration that is used by both apps for both development and production was extracted to webpack_config/webpack.isomorphic.js
  3. CircularDependencyPlugin was added
  4. Some documentation about testing, env variables, i18n and semantic-ui-react

Dev will be merged into master soon when I'll finish docs and README.md.

@TheDolo waiting for you to adopt new features. You're the most active user of this starter, probably 👍

@ghost
Copy link
Author

ghost commented Aug 9, 2017

Yup, FOUC after deploying to a live server. Will get your new updates in a few days and report back! I've gotten good at swapping out all code except my custom routes, reducers, and containers (and some minor code there). It's actually pretty painless! Could easily see a CLI!

@Metnew
Copy link
Owner

Metnew commented Aug 9, 2017

CLI will be soon, sorry, have a lot of work on docs.
I hope you figure out what the hell is currently in /webpack_config. There were some changes to make code follows DRY principle.

@ghost
Copy link
Author

ghost commented Aug 9, 2017

Heh yea docs for sure first. At this point I understand nearly all your code, but that did take a while! I love what you did with webpack_config vs the last refactor! +2000 points for the GA/Sentry integrations. I've still kept the API server separate from the SSR server! But it would be nice to mount/remount the API calls ON server instead of browser.

@Metnew
Copy link
Owner

Metnew commented Aug 9, 2017

docs folder.
Maybe the starter needs more integrations, what do you think about it?
Also, I didn't understand (sorry for bad English). Is last update of webpack_config not so good?

@ghost
Copy link
Author

ghost commented Aug 9, 2017

Np! I love what you did with webpack_config this time around versus the single folder! Much better than before! I was actually going to request a GA integration, it's almost always a requirement, and the Sentry was just the topping on the sundae. What other major services are there? Minds blank!

@Metnew
Copy link
Owner

Metnew commented Aug 9, 2017

Hah, thanks :)
Right now only Sentry and GA for the client, but Sentry for the server is very soon.

I'm currently working on the styleguide for the folder structure. I got some problems in a similar project, where my friend and I used a lot of relative imports (e.g. import {lol} from 'almost-a-root-dir' ). And we have had many circular dependencies until today.

So, maybe this doc about avoiding circular dependencies will be added too, I've never faced a similar guide for frontend before. Of course, there are similar guides for other languages/frameworks because it's OOP basics, but not for React/Redux projects for sure.

@ghost
Copy link
Author

ghost commented Aug 10, 2017

Style guide is perfect, I was a bit confused on how to use scss in the project properly.

Plugs: Further integration of GA into your route system would be nice! And maybe official 'guest' routes tags (x2 please), and the sidebar only shows certain routes if guest. And maybe.... :D

@ghost ghost closed this as completed Aug 12, 2017
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant