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.