Is jquery attr () asynchronous?

Let's say I have a loop that adds a div with an img tag at each iteration, then loads its src attribute using something like this:

$("img").last().attr('src', imageSource); 

If I do this for several iterations for several different images, do I get asynchronously loading these images?

If not, how can I upload images asynchronously, looping? I will be happy to get some ajax tips.

+4
source share
1 answer

attr not asynchronous. This is a very simple operation that is effective instantly.

However, downloading images from the server takes a lot of time. This process is asynchronous: once you set the attribute, you can forget about it, and the browser will download the image for you in the background.

Downloading images asynchronously is not an option: this is actually the only way to download images.

+9
source

Source: https://habr.com/ru/post/1432574/


All Articles