Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Why use less Iframe?

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will tell you why we should use Iframe less. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.

The following figure shows how time-consuming it is to create iframe in 100 different elements.

Time-consuming to create 100th elements

Pages that use iframe generally don't contain much iframe, so it doesn't take a lot of time to create DOM nodes. But it brings some other problems: onload events and connection pooling (connection pool).

Iframes blocks page loading

It is important to trigger the onload event of window in a timely manner. The onload event triggers the browser's busy indicator to stop, telling the user that the current web page has been loaded. When the onload event loads late, it gives the user the impression that the page is very slow.

The onload event for window will not be triggered until all the iframe has been loaded (including the elements inside). In Safari and Chrome, this blocking can be avoided by dynamically setting the SRC of iframe through JavaScript.

Unique connection pool

Browsers can only open a small number of connections to web servers. Older browsers, including Internet Explorer 6 & 7 and Firefox 2, can only open two connections to one domain name (hostname) at the same time. This limit has been raised in the new version of the browser. Safari 3 + and Opera 9 + can open 4 connections to a domain name at the same time, and Chrome 1 connection, IE 8 and Firefox 3 can open 6 connections at the same time. You can view the specific data sheet through this article: Roundup on Parallel Connections.

Some people may wish that iframe would have its own independent connection pool, but this is not the case. Most browsers, the main page and the iframe in it share these connections. This means that iframe may have used up all available connections when loading resources, thus blocking the loading of the main page resources. This is certainly good if the content in the iframe is more important than the content on the main page. But in general, the content in the iframe is not as important as the content on the main page. At this point, it is not worth running out of available connections in iframe. One solution is to dynamically set the SRC of iframe after the important elements have been loaded on the main page.

Iframe is used by the top 10 websites in the United States. In most cases, they use it to load ads. This is understandable and a logical solution to load advertising services in a simple way. But keep in mind that iframe can have an impact on your page performance. Do not use iframe whenever possible. Use them carefully when you really need them.

That's why you need to use less Iframe, and you can search for previous articles or browse the following articles to learn more about why you should use Iframe less. I believe the editor will add more knowledge to you. I hope you can support it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report