Sumit Aggarwal
Sumit Aggarwal

Reputation: 841

How to load the CSS first in node.js and express?

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

Answers (2)

raduken
raduken

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

Sapotero
Sapotero

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

Related Questions