Skip to content

Instantly share code, notes, and snippets.

@ShinyChang
Created March 31, 2019 15:07
Show Gist options
  • Save ShinyChang/8ce3268223badb58b9567299da622f87 to your computer and use it in GitHub Desktop.
Save ShinyChang/8ce3268223badb58b9567299da622f87 to your computer and use it in GitHub Desktop.
resources = window.performance.getEntriesByType("resource");
images = resources.filter(
r => r.initiatorType === "img" && /products\/image/.test(r.name)
);
total = images.reduce((acc, r) => acc + r.duration, 0);
avg = total / images.length;
console.log(avg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment