Skip to content

Instantly share code, notes, and snippets.

@cvazac
Last active September 14, 2016 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvazac/1498565ca958f6d67f82e1c5360ca631 to your computer and use it in GitHub Desktop.
Save cvazac/1498565ca958f6d67f82e1c5360ca631 to your computer and use it in GitHub Desktop.
(function(w) {
if (w != top) return
w.addEventListener('load', function() {
var iframe = document.createElement('iframe')
iframe.style.display = 'none'
iframe.src = location.href
document.body.appendChild(iframe)
iframe.addEventListener('load', function() {
var outer = w.performance
var inner = arguments[0].target.contentWindow.performance
outer.getEntriesByType('resource').forEach(function(resource) {
var found = inner.getEntriesByName(resource.name, 'resource')
if (found && found.length != 0) {
if (found[0].duration > (resource.duration / 10))
console.info(resource, resource.name, resource.duration, found[0].duration)
}
})
iframe.parentNode.removeChild(iframe)
})
})
})(window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment