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

157
Views
Violation: 'setTimeout' handler took XXms

Expected behaviour: When i am on a page for x amount of time, once that time expires when i press back on the window i am redirected to a custom page of my choice, in this case google.

My code works however i noticed in the console i am getting a log that says "[Violation] 'setTimeout' handler took XXms"

Why does this happen? Is there another way to write what i am trying to achieve that is more performant perhaps using new Date() ?

        let redirect = false;

        const ref = setTimeout(() => {
            redirect = true;
            console.log('history');
        }, 5000);

        addEventListener('popstate', (event) => {
            if (redirect) {
                clearTimeout(ref);
                event.preventDefault();

                window.location.href = "https://www.google.com/"
            }
        });
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!