var img=new Image();
img.src='xxxxx';
Will the browser wait for the image to load then execute the next code line?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That action is asynchronous; a lot of image ‘pre-loading’ code relies on that feature.
EDIT: To give a little bit more useful information as well. If you’re wanting to have certain actions synchronously wait for images to load via javascript’s image object, you can use the onload event, like so: