Random Blocking with Javascript-File?

两盒软妹~` 提交于 2019-12-06 07:49:35

Imagine a cursor moving through the HTML document from top to bottom. At each element the cursor is at, it resolves the element/image. When an image is encountered, an image load is started and the cursor moves on, the image doesn't need to be loaded for the renderer to continue.

Once the cursor hits a script tag it first loads that script and then executes it before proceeding to the next element. It basically holds that script tag to be high priority and will only proceed once the script is fully resolved; loading, evaluation and execution.

So any HTML (image or otherwise) that comes after the script tag is put on hold.

This is what is meant with JS Blocking and occurs when scripts are inserted using plain HTML.

This can be avoided by inserting scripts using JavaScript, because though you create HTML elements and append them to the DOM, it does not interrupt the HTML rendering cursor since thats another process entirely.

not an answer, just a screenshot to illustrate the question: why is the download of the last image only started after the javascript has stopped downloading?

and here a possible answer: i put the html of the example on my server (all images and javascripts still on souders's server) and then looked at firebug: now i see the traditional blocking behavior:

loading the first javascript (util.js) blocks the loading of all the following images, loading the second javascript (the slow on) blocks the loading of all images after that.

maybe having the html and the scripts on the same server is some kind of special case that is treated differently by the browsers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!