I am developing a simple website for cars dealership. I am new to Laravel and this is the first time I deal with such thing, actually this is the first time I see something like this in an application that I developed.
So I understand the problem, the browser renders HTML before it applies CSS style, sounds logical to me. However, I don't see any of these anywhere else but my Laravel application?
I read some questions and articles about this and none of the solutions worked for me.
Questions: How do other websites overcome this problem, I don't see it in StackOverflow for insance?
Why it happening, I optimized my pageload to maximum and it still flashes on localhost! the website is not yet on any server.
Here is a screenshot of the website loading time (keep in mind that this is from localhost)
I've tried the following:
On the top of the page:
<script>
// Alternative to load event
document.onreadystatechange = function () {
if (document.readyState === 'complete') {
document.body.style.visibility = 'visible';
}
}
</script>
<body class="g-sidenav-show bg-gray-100 g-sidenav-pinned" style="visibility: hidden !important;"> the rest of the code ... </body>
Also tried:
window.onload = (event) => {
document.body.style.display = "block !important";
console.log("Loaded!!!!")
};
Nothing actually worked!