Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Javascript: Trigger event before a lazily loaded image gets requested by the browser

I like to display lazy loaded images in my web-app using loading="lazy". The problem I have is that the client needs to have a time limited token to request images from the server.

If an image scrolls onto the viewport, the client needs to request a token and with this token the client can request the image. For doing so, I need some kind of event or trigger to be fired before the lazy loaded image is requested by the browser.
I can not send the token with the first page hit or somewhere inbetween because I do not know how long the user is visiting other parts of the app before the images get visible. The time varies between some seconds and hours.

<img onload="doStuff()" /> gets fired after the image has been loaded. This is too late. I need something before the image is requested.

I'm not bounded to use images or loading="lazy" to resolve this issue. Any workaround is also welcome.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!