📜 ⬆️ ⬇️

Download scripts browsers: news from the field

How do browsers handle parallel loading of scripts?

At the time of IE7 and Firefox 2.0, no browser loaded scripts in parallel with other resources. Instead, old browsers blocked all subsequent requests until full download, parsing and script execution. This is what the HTTP request log looked like when it was blocked in older browsers:

HTTP requests
')
There are six HTTP requests on the test page for which this diagram was generated:

The diagram shows how the scripts block each other, as well as a picture, a style file and an iframe. The latter are loaded parallel to each other, but only after the sequential loading of scripts is completed.

Most likely, the reason for the sequential loading of scripts in old browsers was to preserve the order of execution. This is critical when the code in the second script depends on the variables in the first. Preserving the order of execution solves the problem of undefined variables. However, the loss of profit is obvious - as long as the browser loads the first script and guarantees its execution first, it could load the other four resources in parallel.

Glory to new browsers, they load scripts in parallel!

This is a great victory for modern web applications, often consisting of 100K + javascript code, divided into several files. Loading the same page in IE8, Firefox 3.6, Chrome 4 and Safari 4 leads to the following diagram:

HTTP requests

The situation has improved, but not as much as it could. In this case, IE8 loads two scripts and a style file in parallel, but the picture and iframe are locked. In all modern browsers there are similar limitations associated with the types of resources that can be loaded in parallel with the scripts. The table from Browserscope shows the current progress of this issue. The “Compare” button, recently added to Browserscope , made it easier to create such reports.

Browser Comparison

When loading scripts, IE8 still blocks images and iframe. Chrome 4, Firefox 3.6 and Safari 3.6 only block iframes. Opera 10.10 blocks all types of resources. I am sure that parallel loading of scripts will be improved, judging by the significant progress in recent versions of browsers. Let's follow the future versions and note the improvements in this issue.

Source: https://habr.com/ru/post/83370/


All Articles