Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda