TruMan1
TruMan1

Reputation: 36098

Loading splash page while HTML styles and scripts get rendered?

I have all my JavaScript files linked on the bottom of my page. This way, the HTML can get rendered before loading any of the scripts. The only problem is that the HTML shows to the user before the scripts finish "decorating" the HTML elements. Is there an elegant way to show the user a splash page to your app before the scripts and styles kick in?

Upvotes: 2

Views: 4226

Answers (2)

Shi
Shi

Reputation: 4258

You can create a div with position: fixed and a high z-index covering the whole screen as first element in body. A loading animation or text can be shown inside.

The very last line of the body then is a JavaScript which sets display: none to that div.

Upvotes: 3

PeeHaa
PeeHaa

Reputation: 72672

In your HTML you can write you splash page and overwrite this with real content (which is hidden by default) by using javascript once it is loaded.

However there is a huge drawback to this solution: what if somebody has JS disabled?

Demo: http://jsfiddle.net/FDcNx/

Upvotes: 0

Related Questions