when is image pulled from the server createElement

P

polilop

I am creating img elements on the fly (document.createElement('img)
so now i am interested when is the image being pulled from the server, is it
whe i start creating the elements or when i append the elements to the
document?
 
M

Martin Honnen

polilop said:
I am creating img elements on the fly (document.createElement('img)
so now i am interested when is the image being pulled from the server,
is it whe i start creating the elements or when i append the elements to
the document?

Well simply creating e.g.
var img = document.createElement('img');
can't pull anything from the server.
Whether setting
img.src = 'foo.png';
then (pre)loads the image depends on the implementation, you will have
to run a test.
 
R

rf

polilop said:
I am creating img elements on the fly (document.createElement('img)
so now i am interested when is the image being pulled from the server, is
it whe i start creating the elements or when i append the elements to the
document?


What happened when you stepped through your code with the debugger and
watched the net tab? Using firefox and firebug of course.
 
P

polilop

images ar loaded when src attribute is added, or when img element is
created.
Happens very fast as I first create img then add attribute in next line, but
it is not when appending to page.
conclusion: when img object created then the image is getting transferred
from server/image location
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top