Reputation: 2298
in this page it's said :
When your webpage loads, the browser takes certain steps that determine how the page will load (this is a simplified version, but basically what happens): Browser downloads HTML file It parses (looks through) the HTML It encounters something it must load (image, external CSS file, etc.) and stops parsing HTML It loads the external resource If external resource is CSS or Javascript it then parses that file It then continues to parse the HTML until it comes to another resource that must be loaded
So why alot people (and myself) were looking for a solution to capture load event on LINK and to detect When is a stylesheet really loaded as we can be sure that a browser won't dislpay a non-styled html if we place its css before it?
Upvotes: 0
Views: 94
Reputation: 15168
There may not be a need to detect this but plenty of reasons to do so. If your CSS is sizing an element, or using pseudo elements that add content to your document, you may wish to know when the CSS has completed loading before trying to manipulate those same elements.
For example, if your CSS is loading an image, and that image winds up resizing other elements on the page, you may not want your javascript interfering with that sizing before it's complete.
If you add elements with CSS ::before or ::after, you want those elements inserted before allowing javascript to manipulate them.
But if you aren't doing such things, then you don't need to detect them.
Upvotes: 1