Can Onload Event Fire Right After Setting Image Src Attribute?
What console log can be after this code will be executed? var img = new Image; img.onload = function() { console.log('B'); }; img.src = 'image.jpg'; for (var i=0;i<100000;i++) {
Solution 1:
It can be any of them. You don't know how long it takes to load the image. The image could even be cached, minimizing the loading time.
Post a Comment for "Can Onload Event Fire Right After Setting Image Src Attribute?"