Test JS asynchronous loading

Source: Internet
Author: User
Test results for IE8 and firefox3.6:
1. Normally, using the script tag in the head to reference JS is no longer blocking mode loading (that is to say, the script file is no longer loaded one by one, but loaded one by one), but the most

Loading starts at the same time (the maximum number of concurrent operations is 6). However, the execution sequence of scripts is still in the script tag order, which hinders page rendering.
2. use document. write ("<SCRIPT>... </SCRIPT> ") (this method is invalid for Firefox) and head. append (SCRIPT) (this method is compatible with IE and Firefox)

Asynchronous loading is of little significance.
3. However, using head. append (SCRIPT) does not impede the display of the interface, but note the following:
(1) If. the onload event trigger has an impact: in IE, window. the onload event is triggered immediately after other elements on the page are loaded (that is, you do not have to wait until all scripts are loaded

The window. onload event in Firefox is triggered only after the dynamically added script files are loaded.
(2) Although the script elements we dynamically load are strictly ordered, the browser may not necessarily think so. In Firefox, script files are executed in the order of script elements that are dynamically loaded.

And IE is executed according to the script file download sequence.

Note:
1. in IE6 and IE7, the regular use of the script label in the head to reference JS is blocking mode loading. That is to say, a JS must be loaded before loading the next Js.
2. in IE6 and IE7, The concurrency limit is 2. That is, even if the head. append (SCRIPT) method is used to asynchronously load three JS files, the third JS file will be loaded only after the first two JS files are loaded.

Test Tools: firebug, Fiddler, httpwatch

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.