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

111
Views
Is it possible ot truely reload the image?

I am trying to determine the speed of loading an image by average

My code looks something like this

function test(){
    const now = performance.now();
    const image = new Image();
    image.src = "https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/1200px-Wikipedia-logo-v2.svg.png"
    image.onload = function(){
        const end = performance.now(); 
        const speed = end-now
        console.log(speed)
    }
}
setInterval(test,1000)

The code works fine, but the problem is after the image loaded for the first time, it will loaded very first from about (64ms to less than 1 ms in my side).

My guess is the broswer will keep some data of the image until the window reloaded or closed (correct me if I am wrong)

Is it possible to prevent this without using window.reload and truely reload the image??

Example:

enter image description here

Thanks for any responds!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Just add your now as a query parameter to your url:

function test(){
    const now = performance.now();
    const image = new Image();
    image.src = `https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/1200px-Wikipedia-logo-v2.svg.png?${now}`
    image.onload = function(){
        const end = performance.now(); 
        const speed = end-now
        console.log(speed)
    }
}
setInterval(test,1000)

about 4 years ago · Juan Pablo Isaza Report
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!