Skip to content

Commit

Permalink
Boomerang Loader Snippet v10
Browse files Browse the repository at this point in the history
  • Loading branch information
nicjansma committed Apr 4, 2018
1 parent 603d5da commit 0264088
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,18 @@ For boomerang, the asynchronous loader snippet you'll use is:
```html
<script>
(function(){
if (window.BOOMR && window.BOOMR.version) { return; }
var dom,doc,where,iframe = document.createElement("iframe"),win = window;
// Boomerang Loader Snippet version 10
if (window.BOOMR && (window.BOOMR.version || window.BOOMR.snippetExecuted)) {
return;
}
window.BOOMR = window.BOOMR || {};
window.BOOMR.snippetExecuted = true;
var dom, doc, where, iframe = document.createElement("iframe"), win = window;
function boomerangSaveLoadTime(e) {
win.BOOMR_onload=(e && e.timeStamp) || new Date().getTime();
win.BOOMR_onload = (e && e.timeStamp) || new Date().getTime();
}
if (win.addEventListener) {
Expand All @@ -190,29 +197,30 @@ For boomerang, the asynchronous loader snippet you'll use is:
}
iframe.src = "javascript:void(0)";
iframe.title = ""; iframe.role = "presentation";
(iframe.frameElement || iframe).style.cssText =
"width:0;height:0;border:0;display:none;";
iframe.title = "";
iframe.role = "presentation";
(iframe.frameElement || iframe).style.cssText = "width:0;height:0;border:0;display:none;";
where = document.getElementsByTagName("script")[0];
where.parentNode.insertBefore(iframe, where);
try {
doc = iframe.contentWindow.document;
} catch(e) {
} catch (e) {
dom = document.domain;
iframe.src="javascript:var d=document.open();d.domain='"+dom+"';void(0);";
iframe.src = "javascript:var d=document.open();d.domain='" + dom + "';void(0);";
doc = iframe.contentWindow.document;
}
doc.open()._l = function() {
var js = this.createElement("script");
if (dom) { this.domain = dom; }
if (dom) {
this.domain = dom;
}
js.id = "boomr-if-as";
js.src = 'http://your-cdn.host.com/path/to/boomerang-<version>.js';
BOOMR_lstart=new Date().getTime();
BOOMR_lstart = new Date().getTime();
this.body.appendChild(js);
};
doc.write('<bo' + 'dy onload="document._l();">');
doc.close();
})();
Expand Down
30 changes: 21 additions & 9 deletions tests/page-template-snippets/boomerangSnippetNoScript.tpl
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
(function(){
if (window.BOOMR && window.BOOMR.version) { return; }
var dom,doc,where,iframe = document.createElement("iframe"),win = window;
// mPulse Loader Snippet version 10
if (window.BOOMR && (window.BOOMR.version || window.BOOMR.snippetExecuted)) {
return;
}

window.BOOMR = window.BOOMR || {};
window.BOOMR.snippetExecuted = true;

var dom, doc, where, iframe = document.createElement("iframe"), win = window;

function boomerangSaveLoadTime(e) {
win.BOOMR_onload=(e && e.timeStamp) || new Date().getTime();
win.BOOMR_onload = (e && e.timeStamp) || new Date().getTime();
}

if (win.addEventListener) {
win.addEventListener("load", boomerangSaveLoadTime, false);
} else if (win.attachEvent) {
win.attachEvent("onload", boomerangSaveLoadTime);
}

iframe.src = "javascript:void(0)";
iframe.title = ""; iframe.role = "presentation";
iframe.title = "";
iframe.role = "presentation";
(iframe.frameElement || iframe).style.cssText = "width:0;height:0;border:0;display:none;";
where = document.getElementsByTagName("script")[0];
where.parentNode.insertBefore(iframe, where);

try {
doc = iframe.contentWindow.document;
} catch(e) {
} catch (e) {
dom = document.domain;
iframe.src="javascript:var d=document.open();d.domain='"+dom+"';void(0);";
iframe.src = "javascript:var d=document.open();d.domain='" + dom + "';void(0);";
doc = iframe.contentWindow.document;
}

doc.open()._l = function() {
var js = this.createElement("script"), prefix, suffix;
if (dom) { this.domain = dom; }
if (dom) {
this.domain = dom;
}
js.id = "boomr-if-as";
if (window.BOOMR_script_delay) {
prefix = "/delay?delay=3000&file=build/";
Expand All @@ -37,9 +49,9 @@
suffix = "";
}
js.src = prefix + (window.BOOMR_script_minified ? "boomerang-latest-debug.min.js" : "boomerang-latest-debug.js") + suffix;
BOOMR_lstart=new Date().getTime();
BOOMR_lstart = new Date().getTime();
this.body.appendChild(js);
};
doc.write('<body onload="document._l();">');
doc.write('<bo' + 'dy onload="document._l();">');
doc.close();
})();

0 comments on commit 0264088

Please sign in to comment.