Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iframe for ad loading 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.

like image 359
Cedar Jensen Avatar asked Apr 12 '10 23:04

Cedar Jensen


People also ask

Is iframe good or bad?

Iframes Cause SEO Problems. Google recommends refraining from creating iframes. At there Webmasters Help Forum, Google clearly stated that iframes may cause problems for them: IFrames are sometimes used to display content on web pages.

Are iFrames bad for performance?

iFrames tend to neither help nor hurt your search engine ranking. For this reason, it's best to refrain from using iFrames on main pages that you want to rank high in search engine results. Instead, fill high-priority pages with useful, unique content and save iFrames for other pages.

Do iFrames slow down page load?

So, you should not use iframe excessively without monitoring what's going on, or you might end up harming your page performance. To avoid having your iframes slow down your pages, a good technique is to lazy load them (i.e., loading them only when they are required like when the user scrolls near them).


2 Answers

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.

like image 192
dthorpe Avatar answered Oct 10 '22 21:10

dthorpe


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).

like image 23
tloflin Avatar answered Oct 10 '22 21:10

tloflin