D
D
Denis Bukreev2017-08-31 08:40:23
JavaScript
Denis Bukreev, 2017-08-31 08:40:23

Why is it that when the image is fully loaded, it still renders when inserted into the DOM?

So it goes.

I have a bunch of pictures that change dynamically.
Before using, I load each:

let i = 1;
            function loadImage () {
                let img = new Image();
                img.onload = () => {
                    if (i === count) {
                        resolve();
                    } else {
                        i++;
                        loadImage();
                    }
                };
                img.src = path;
            }
            loadImage();


And when I insert them directly into the DOM, they start rendering! Moreover, many of them are rendered partially and this is terribly annoying.

What can be done about it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim, 2017-08-31
@de_arnst

This is how browsers work.
I usually did this:
The browser does not render the same image a second time, but takes the old one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question