Exercise caution when using the IFRAME framework _ HTML basics _ front-end technology

Source: Internet
Author: User

 

ArticleFrom: http://www.8823513.cn/html/483-31/31214.htm

 

IFRAME can be used to easily call pages of other websites, but it should be used with caution. It consumes dozens or hundreds of times more performance than creating other DOM elements (including style and script.

Tutorial on creating HTML web pages: Use IFRAME (framework) tags with caution

IFRAME can be used to easily call pages of other websites, but it should be used with caution. It consumes dozens or hundreds of times more performance than creating other DOM elements (including style and script. The onload event and connection pool are worth noting.

IFRAME blocks onload

It is very important to execute the onload event of window as soon as possible. This completes the loading progress indicator of the browser. You can determine whether the page has been loaded. The onload event delay will make the user feel that the page is slow.

The onload event of window will not be triggered until all IFRAME contained in it and the resources in all IFRAME are fully loaded. In safari and chrome, using javascritpt to dynamically assign values to the SRC of IFRAME can avoid this blocking behavior.

One connection pool

For each web server, the browser only opens a few connections. Old browsers, including IE 6/7 and Firefox 2, each host has only two connections. In the new browser, the number of connections increases. Safari 3 + and opera 9 + increased to 4, chrome 1 +, IE 8, and Firefox 3 increased to 6.

People may expect that each IFRAME has a separate connection pool, but this is not the case. In most browsers, the connection is shared by the home page and Its IFRAME, which means that resources in the IFRAME may occupy available connections and block loading of resources on the home page. This is good if the content in IFRAME is equally important or more important than the home page. However, in general, the content in IFRAME is not very important to the page, and the number of connections occupied by IFRAME is not desirable. A solution is to dynamically assign values to the SRC of IFRAME after resources with higher priorities are downloaded.

Five of the top 10 websites in the United States use IFRAME. Most of them are used to load advertisements. This is not very suitable, but it is understandable that it is a simple way to insert advertisements into the content. In many cases, it is reasonable to use IFRAME. But be aware of the impact on the performance of your page. Exercise caution when not necessary.

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.