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:
Written by Jason Ormand
Related protips
2 Responses
Nice ideia.
I wrote my own version without the lodash/underscore dependency.
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Chrome
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#