I am learning front-end web developing best practice and encountered these two concepts - "render-blocking CSS" and "FOUC (Flash of Unstyled Content)".
However, these two concepts seem contradictory to me. Here's my understanding:
- Browsers parse an HTML from top to bottom, and try to render content ASAP. Putting CSS at the bottom of the page will cause an FOUC issue.
- CSS is a render-blocking resource. Browsers won't render anything until the CSSOM is constructed (all CSS files are loaded)
Here're my questions:
- If a browser parse and render a page from top to bottom, how does it know if there are more CSS files or not during the process?
- If a browser knows how many CSS files it should fetch before start rendering, why does the FOUC problem still exist?
Thanks all for your time in reviewing my questions, and please correct me if I misunderstand anything.