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

101
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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