Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda