A
A
Alex Xmel2020-06-30 21:21:46
Django
Alex Xmel, 2020-06-30 21:21:46

How to avoid pause on page load?

Created my first website in django. Everything is ok, but I noticed one unpleasant feature. I go to the site (on the local or on the network already, it doesn’t matter) and when I go through different pages, I see that the white background is loaded first with the page from the template - this is a small part of the page, then the rest of the page is generated using js and css is applied. As a result, there is a difference between the rendering of the template on the server and the user somewhere in half a second or even less. It infuriates terribly, looks like a one-time flicker when entering a new page.
I use djano, without DRF, I give the data in json at the endpoint. The page is generated on the client. I use pure js and css.
What could be the problem ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-07-01
@pyHammer

Desead can only guess. This is not related to Django, but due to the fact that you placed all the uploaded files in the head. Due to the fact that the browser reads the page with faith down, the following happens:
- First, the browser sees the styles, loads them.
- Then he sees the scripts and starts downloading them.
- Only after loading all the resources from the head, the browser reads the page further, that is, the body.
So it turns out that you see a white page while you wait for the browser to load all the resources from the head.
To avoid this, minimize resource calls to the head and move all script tags to the end of the body.
And also, since you are rendering the page on the client, this delay will always be there. To level it, you need to make a preloader. Preloader styles should be placed as early as possible in the head, and not as an included file, but directly in the head in the style tag. The preloader is displayed by default, and already in js, after all the manipulations, you hide it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question