Can a resource slow down a webpage load?
If I call a resource in a webpage (e.g. a pixel from tracker.com at the beginning of body), and tracker.com is very slow to answer (e.g. >10s or even timeout), what are the consequences to my webpage load?
Will the other resources开发者_JS百科 (script, images, css, etc) be displayed as usual? If not, is asynchronous tag an option?
Loading resources, as you call it, will not delay the domready
or document ready
page event, however it will delay the load
page event. The actual behaviour of page loading depends on browser - the browser should download the resources from different hosts in paralel. It will not affect the whole page rendering, unless you use images with unspecified width and height - in that case browser must re-render the page after receiving the image.
So when well designed, the only problem would be the delayed load event.
In case of very slow-loading resources you can avoid that by the use the "asynchrounous tag" - just handle the domready event and place new tags. E.g. in jquery use:
$(function () {
// this code will be run after dom ready event
});
精彩评论