0

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?

2
  • setTimeout with document ready inside makes no sense Commented May 11, 2019 at 4:35
  • How so? setTimeout executes after the document is ready Commented May 11, 2019 at 4:53

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

The overlay loads inside the body; setting the body's opacity to 0 hides the overlay too
Not the body as a tag but the contents of the page. There must be a parent div that acts as a container. That one can be hidden at the beginning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.