Reputation: 841
I am working in node.js and using ejs for my front end programming. While loading the page, it displays all the content in an unmanaged way but after loading the CSS its show correct layout.
Is there a way to load the CSS first so that the page shows / loads correctly? I heard that there is a way related to async, although I don't know how to use the function properly.
Upvotes: 0
Views: 105
Reputation: 2119
1 - hide all the page
<body style="display: none;">
2 -With jQuery show all, when all files are loaded:
<script>
$(window).load(function() {
$("body").show();
});
</script>
or jQuery instead $:
<script>
jQuery(window).load(function() {
$("body").show();
});
</script>
Upvotes: 0
Reputation: 179
Put
<link href="/public/css/simple-sidebar.css" rel="stylesheet">
in begining of HEAD, and CSS will load before page will render
Upvotes: 1