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

187
Vistas
How to architect a JS widget to be embedded in different websites

I know this is vague, but I want to create a JS widget that can be embedded into webpages and the user can interact with. Similar to what these guys do with their chatbot widget.

It looks like they use an iframe. If I want to package up some code and make it easy to embed into other websites, is there a benefit to using an iframe? Is it something to do with cookies tracking etc.?

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

To build a JS widget, you have many alternatives, I will describe two of them below :

1- Using an iFrame : this approach is the easiest one to implement, the only cons is that your widget code won't be able to interact with the host's webpage content. And vice versa, your host web application code won't be able to interact with your iFrame content. To implement this approach, you will have to host your iFrame content and reference it in an iFrame tag inside your host application.

2- Making a HTML renderer module : this approach is the most customizable. How it works : You will have to make a JS script that renders your HTML content. Example : Imagine your host website's code is as follows :

   

     // widget.js
        const widgetContentEl = document.getElementById('widget-content');
        var myWidget = document.createElement('div');
        myWidget.innerHTML = '<h1> This is my widget</h1> <p> And this is a paragraph in my widget';
        widgetContentEl.appendChild(myWidget);
<!-- index.htm -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Example host</title>
  </head>
  <body>
  <div id="widget-content"></div>
    <script src="widget.js"></script>
  </body>
</html>

This way, you can customize the widget.js content to render your widget.

I hope my answer was helpful.

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