Last Updated: February 25, 2016
·
739
· okor

Generate a sorted list of unique domains used to load assets on a web page

Requires LoDash or Underscore and Google Chrome. After loading the page, execute the following:

var domainStats = _.map(performance.getEntries(), function(e){ 
  return { domain: e.name.split(/http\:\/\/|https\:\/\//)[1].split('/')[0] };
})

var uniqueDomainStats = _.uniq(domainStats, function(stat) { 
    return stat.domain;
})

var sortedUniqueDomainStats = _.sortBy(uniqueDomainStats, function(stat){
  return stat.domain;
})

console.table(sortedUniqueDomainStats);

Which will generate something that looks like this:

Picture

2 Responses
Add your response

Nice ideia.

I wrote my own version without the lodash/underscore dependency.

https://gist.github.com/txgruppi/4e9580f08a1f02c64624

over 1 year ago ·

Even better. I was lazy since they are typically already loaded for the stuff I do day to day. But for a snippet like this, removing dependencies is a great idea.

over 1 year ago ·