Browse files

document iframe usage

  • Loading branch information...
1 parent 023d35b commit 1edd63297d18e4ce3476be702b677a542eac0e4d @bluesmoon bluesmoon committed Oct 30, 2012
Showing with 31 additions and 0 deletions.
  1. +31 −0
@@ -51,6 +51,7 @@ Install this file on your web server or origin server where your CDN can pick it
### 3. Asynchronously include the script on your page
+#### 3.1. Adding it to the main document
Include the following code at the *top* of your HTML document:
@@ -69,6 +70,36 @@ way will not block other resources, however it _will_ block <code>onload</code>.
before the rest of your page does thereby reducing the probability of it blocking the `onload` event. If you don't want to block `onload` either, follow Stoyan's
<a href="">advice from the Meebo team</a>.
+#### 3.2. Adding it via an iframe
+The method described in 3.1 will still block `onload` on most browsers (Internet Explorer not included). To avoid
+blocking `onload`, we could load boomerang in an iframe. Stoyan's <a href="">documented
+the technique on his blog</a>, so read that for the details.
+For boomerang, this is the code you'll include:
+ var iframe = document.createElement('iframe');
+ iframe.src="javascript:false";
+ (iframe.frameElement || iframe).style.cssText = "width: 0; height: 0; border: 0";
+ var where = document.getElementsByTagName('script')[0];
+ where.parentNode.insertBefore(iframe, where);
+ var doc = iframe.contentWindow.document;
+'<body onload="'+
+ 'var js = document.createElement(\'script\');'+
+ ' = \'boomr-if-as\';'+
+ 'js.src = \'<version>.js\';'+
+ 'document.body.appendChild(js);">');
+ doc.close();
+The `id` of the script node created by this code MUST be `boomr-if-as` as boomerang looks for that id to determine if it's running within an iframe or not.
+Boomerang will still export the `BOOMR` object to the parent window if running inside an iframe, so the rest of your code should remain unchanged.
Documentation is in the docs/ sub directory, and is written in HTML. Your best bet is to check it out and view it locally, though it works best through a web server (you'll need cookies).

0 comments on commit 1edd632

Please sign in to comment.