Skip to content

Instantly share code, notes, and snippets.

@cvazac
cvazac / gist:cb96774bd62f7eb29f63
Created May 8, 2015
average response time by domain
View gist:cb96774bd62f7eb29f63
;(function(domains)
{
var entries = window.performance.getEntries();
var result = {
total: 0,
count: 0,
domains: {}
};
for (var entry = 0; entry < entries.length; entry++)
@cvazac
cvazac / gist:fe2666834e7f157a1fe7
Last active Aug 29, 2015
instrument performance getEntries
View gist:fe2666834e7f157a1fe7
;(function(p){
if (!p) return;
function stash(strMethod)
{
p["__orig_" + strMethod] = p[strMethod];
}
stash("getEntries");
stash("webkitClearResourceTimings");
@cvazac
cvazac / gist:c1554c3e9609041725a8
Created May 21, 2015
performance.setResourceTimingBufferSize for SPAs
View gist:c1554c3e9609041725a8
var setResourceTimingBufferSize == window && window.performance && (performance.setResourceTimingBufferSize || performance.webkitSetResourceTimingBufferSize);
if (setResourceTimingBufferSize) {
setResourceTimingBufferSize(<size>);
}
@cvazac
cvazac / gist:f2cd83ea0058246d8e5c
Created May 21, 2015
performance.clearResourceTimings for SPAs
View gist:f2cd83ea0058246d8e5c
(function(w){
if (!w || !w.performance) {
return;
}
var clearResourceTimings = performance.clearResourceTimings || performance.webkitClearResourceTimings;
if (clearResourceTimings) {
BOOMR.subscribe("onbeacon", clearResourceTimings);
}
})(window);
@cvazac
cvazac / gist:34ce10b4b423b3e60c8f
Created May 28, 2015
BOOMR.addVar(...) `onBoomerangLoaded`
View gist:34ce10b4b423b3e60c8f
function addVars() {
BOOMR.addVar({
"UserId": SOASTA.UserId,
"ClientId": SOASTA.ClientId,
"GroupId": SOASTA.GroupId,
"UniqueId": SOASTA.UniqueId
});
}
if (document.addEventListener) {
View clearresourcetimings.js
(function(w){
if (!w || !w.performance) {
return;
}
var clearResourceTimings = w.performance.clearResourceTimings || w.performance.webkitClearResourceTimings;
if (!clearResourceTimings) {
return;
}
View waitForMark.js
(function(w) {
if (!w || !("performance" in w) || !w.performance || !performance.getEntriesByName) {
return;
}
BOOMR = w.BOOMR || {};
BOOMR.plugins = BOOMR.plugins || {};
BOOMR.plugins.WaitForMark = {
markFound: false,
init: function() {
View gptlistener.js
(function() {
//https://developers.google.com/doubleclick-gpt/reference
var slots = ["ad_bnr_atf_01", "ad_bnr_btf_02"],
slotCount = window.performance && performance.mark ? slots.length : 0;
var boomr_ready = false;
BOOMR = window.BOOMR || {};
BOOMR.plugins = BOOMR.plugins || {};
BOOMR.plugins.GPT = {
View taskQueue.js
(function() {
var tasks = []
function run() {
tasks.push(Array.prototype.slice.call(arguments))
waitThenRun()
}
function waitThenRun() {
requestAnimationFrame(function() {
if (tasks.length === 0) {
return
View fetchLinks.js