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

109
Visualizações
Wait sometime before loading a widget onto a page

I'm new to programming and the following code I got through an open source project.

I'm loading a widget on a website. So instead of immediately loading the widget, I want it to take 10 secs before showing the widget.

This is how I'm loading the widget.

Entire code below............

switch (methodName) {
            case 'init':

                const loadedObject = Object.assign(defaultConfig, item[1]);
           
                // the actual rendering of the widget
    
                const wrappingElement =
                    loadedObject.element ?? win.document.body;
                targetElement = wrappingElement.appendChild(
                    win.document.createElement('div')
                );
                targetElement.setAttribute('id', `widget-${instanceName}`);
                render(targetElement, loadedObject);

                // store indication that widget instance was initialized
                win[`loaded-${instanceName}`] = true;
                break;
    
            default:
                console.warn(`Unsupported method [${methodName}]`, item[1]);
        }

    }

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you should use the setTimeout function as such:

switch (methodName) {
  case 'init':

    const loadedObject = Object.assign(defaultConfig, item[1]);       
    setTimeout(function(){
    
      // the actual rendering of the widget
      const wrappingElement =
          loadedObject.element ?? win.document.body;
      targetElement = wrappingElement.appendChild(
          win.document.createElement('div')
      );
      targetElement.setAttribute('id', `widget-${instanceName}`);
      render(targetElement, loadedObject);

      // store indication that widget instance was initialized
      win[`loaded-${instanceName}`] = true;

    }, 10000);

  break;
    
  default:
    console.warn(`Unsupported method [${methodName}]`, item[1]);
    }

}

as shown in this answer here

about 4 years ago · Juan Pablo Isaza Relatório
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