Skip to content

Instantly share code, notes, and snippets.

@gaurigshankar
Last active June 15, 2018 06:00
Show Gist options
  • Select an option

  • Save gaurigshankar/e7a576cab4a00b400676ef1522a341bc to your computer and use it in GitHub Desktop.

Select an option

Save gaurigshankar/e7a576cab4a00b400676ef1522a341bc to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script>
var w;
if(typeof(Worker) !== "undefined") {
if(typeof(w) == "undefined") {
w = new Worker("../webWorker.js");
}
w.onmessage = function(event) {
document.getElementById("result").innerHTML = event.data;
};
} else {
document.getElementById("result").innerHTML = "Sorry! No Web Worker support.";
}
if ( document.addEventListener ) {
document.addEventListener("DOMContentLoaded", function(event) {
console.log("Hi DOMContentLoaded")
var entries = JSON.parse(JSON.stringify(performance.getEntries()));
w.postMessage({
topic: "gauri",
htmlEvent: "DOMContentLoaded",
content: entries
});
});
window.addEventListener("load", function(event) {
console.log("Hi DOMContentLoaded")
var entries = JSON.parse(JSON.stringify(performance.getEntries()));
w.postMessage({
topic: "gauri",
htmlEvent: "onLoad",
content: entries
});
});
}
</script>
</head>
<body>
<div id="result"></div>
</body>
</html>
this.onmessage = function (msg) {
console.log(msg.data)
var encodedPayload=encodeURIComponent(JSON.stringify(msg.data));
//var url = "https://beacon.walmart.com/rum.gif?perfData="+encodedPayload+"&ts=1528846772150&pv_id=testPixelTracking&a=aValue&ctx=someContext&rp=someReport&callSequenceNumber=4";
var url = "https://beacon.walmart.com/rum.gif?perfData=dummyData&ts=1528846772150&pv_id=testPixelTracking&a=aValue&ctx=someContext&rp=someReport&callSequenceNumber=4";
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment