I prevent FOUC by applying collateral with FOUC, visible only when their CSS is fully loaded. To make it simple, I apply it to the whole body. For instance:
body { opacity: 0; }
Then, later in the CCS file or download some component ...
body { opacity:1; }
This effectively hides elements during rendering while they are still being drawn. By working with this, you can create a unit test to run before loading CSS for your element / component to check the visibility or other CSS properties that need to be loaded before the element becomes visible. The trick would be to have these tests run at the appropriate time at each stage of the element's rendering.
// Test for FOUC load component then verify for no visiblity ... expect($('#testElement').is(':visible')).toBe(false) // then test for visibility or other css properties ... expect($('#testElement').is(':visible')).toBe(true)
source share