Mohammed Baashar
Mohammed Baashar

Reputation: 559

How to load loading script before html document

I'm using a plugin in my website for a loading screen that precedes the loading of the html document, but it doesn't show before the html rather after it loads

Code:

Javascript:

$.LoadingOverlay("show", {
  // Background
  background: "#fff",
  // Text
  text: "Loading...", // String/Boolean
  textClass: "logo_text"
});

setTimeout(function() {

  $(document).ready(function() {
    $.LoadingOverlay("hide");
  });
}, 7000);

The initialization and the calling is that simple, but it shows on the screen after the body loads in a fraction of a second, how can I load it before the body?

Upvotes: 0

Views: 156

Answers (1)

Mihai
Mihai

Reputation: 10717

You cannot load it before the body but you can load the whole body as hidden and then show it when you hide the overlay.

Or you can load only the overlay and while you show it you can make an ajax call to load the body. This one is definitely faster for user experience.

Upvotes: 1

Related Questions