最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - iframe for ad loading good or bad? - Stack Overflow

programmeradmin1浏览0评论

According to Yahoo's "Best Practices for Speeding Up your Site", the pros for using iframes:

  • Helps with slow third-party content like badges and ads
  • Download scripts in parallel

but the cons are:

  • Costly even if blank
  • Blocks page onload

I want to use an iframe to load ads using the technique mentioned on this site: /

Does using this technique mean that as soon as the html contents requested by the iframe are returned to the client, it will load the ad script, potentially blocking the rest of the page's rendering and downloading? Or will the iframe request get processed concurrently while rest of the document is downloaded and rendered?

I'm, however, not looking for a discussion on the philosophy of whether ads are good or bad.

According to Yahoo's "Best Practices for Speeding Up your Site", the pros for using iframes:

  • Helps with slow third-party content like badges and ads
  • Download scripts in parallel

but the cons are:

  • Costly even if blank
  • Blocks page onload

I want to use an iframe to load ads using the technique mentioned on this site: http://meanderingpassage.com/2007/08/15/keeping-javascript-widgets-from-controlling-your-blog/

Does using this technique mean that as soon as the html contents requested by the iframe are returned to the client, it will load the ad script, potentially blocking the rest of the page's rendering and downloading? Or will the iframe request get processed concurrently while rest of the document is downloaded and rendered?

I'm, however, not looking for a discussion on the philosophy of whether ads are good or bad.

Share Improve this question edited Apr 12, 2010 at 23:13 Cedar Jensen asked Apr 12, 2010 at 23:07 Cedar JensenCedar Jensen 2933 gold badges5 silver badges10 bronze badges 3
  • How does it block page onload? And its only costly because of implementation. Blame the browser people, not the original design of iframe. – Pyrolistical Commented Apr 12, 2010 at 23:15
  • 2 @Pyro I don't think he's concerned with blaming anyone, just making a good site. – Frank Schwieterman Commented Apr 12, 2010 at 23:21
  • I've been publishing Google ads for a while on my site, which rely on JS-generated iframes, and have noticed no issues. Generally (but not always) my content is loaded before the adds (and when the ads win the race is because they are text-only and my page is long ^^' ). – Edurne Pascual Commented Apr 12, 2010 at 23:29
Add a comment  | 

3 Answers 3

Reset to default 9

I'm not quite sure why the Yahoo list says "Blocks page onload". IFrames load independently of the parent page, particularly if the iframe content is in a different domain than the main page. The "Blocks page onload" seems contradictory to the pros, both of which are due to concurrency of the iframe load.

Now, if you have an iframe that is loading something from the same domain name as the main page, that may fall into the browser's connection limit per domain, and therefore impact how quickly the main page can download its content. But if the iframe URL is a different domain, it should get its own connection limit per domain.

The biggest pro for iframes is security isolation. When you load third party script into an iframe, you don't have to worry about the third party script taking over your page and scrawling graffitti all over the place, or stealing user data from your script variables.

The biggest con for iframes is also the security isolation. ;> The brick wall that protects you from third parties also makes it very difficult to communicate / share info between parties on the same web page.

Rendering of the interior iframe is processed concurrently with the exterior page. Any javascript inside the iframe will only prevent loading of the contents inside the iframe.

Edit: also, I just noticed I answered your previous question on this subject, and as explained there it's possible to trigger iframe loading in javascript whenever you wish (e.g. after the rest of the page is loaded).

If you're putting in ads, you probably want to use AdSense (or at least test it out). The Google AdSense robot doesn't like iframes:
https://www.google.com/support/adsense/bin/answer.py?hl=en&answer=10035

发布评论

评论列表(0)

  1. 暂无评论