Expected that application behaviour would be the same across different browsers.
In Safari the whole rendering would be suspended while style, added to the head, is loading.
Adding style to the body resolves the problem.
This example reproduces an issue originally created for loadable-components.
It delays serving for .css file for 10 second, and all this time nothing is rendered.
link to the head in Safarylink is loading the dataFor Safari "dynamic" styles has to be added into Body. It resolves the issue.
@evilebottnawi i could pr it appending to the body instead. Or an option could be added to the plugin like ‘appendTo’ thoughts?
First one has to investigate the consequences. Plus should new links be added to the beginning of the body, or appended to the end?
Look like the issue is here already for a while, let's not rush.
@theKashey It is not just style files but js files too could cause the whole rendering suspended. The dom is acutally loaded (we can examine it in the devtools). Should this be reported to webkit?
I would say - it might take a year to resolve this issue _via_ webkit, so some other solution should be created.
inserting styles to <header> is a common practice, it is definitely shouldn't be changed
That's not how you should think about it. Now "what everybody is doing it", but "why everybody is doing it". And really - there is no reason.
For example all CSS-in-JS solution during SSR insert styles or links just before markup, and that's ok. There is no real reason to hoist everything to the head.
All existing studies, proposing keeping "styles in the head" are:
The reason is to start to load CSS as much faster as we can, because CSSOM is blocking JS parsing.
Again, you are speaking about SSR case, but this (JavaScript!) plugin is adding them when application is already half running. In the original issue (code splitting) - when you change your route - everything is already parsed, everything is loaded.
You can fix it using https://github.com/webpack-contrib/mini-css-extract-plugin/pull/609, I think we can close it, because it is not good default behavior, but if you provide more information we can improve it out of box
insert option is capable to mitigate this problem 👍