Skip to content

Instantly share code, notes, and snippets.

@hakimelek
Created June 29, 2018 15:53
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 hakimelek/55c8c79856ccbed995394a63b216e4d0 to your computer and use it in GitHub Desktop.
Save hakimelek/55c8c79856ccbed995394a63b216e4d0 to your computer and use it in GitHub Desktop.
Detect Latest Image loaded on the page
const imagePath = '/path/to/image'
let latestImageTiming = 0
const p = window.performance.getEntriesByType('resource')
p.filter(e => { e.name.indexOf(imagePath) >= 0 && (latestImageTiming = Math.max(latestImageTiming, e.responseEnd))})
console.log(latestImageTiming)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment