4
5 Comments

Help needed to find a guide on embeddable JS widgets

Hi all,

I've been learning JS for a little while practicing on small and simple side projects.

Recently though I faced a challenge where I needed to create a JS widget which I cat distribute on 3rd party websites. It's a small pop up that captures user's input.

Having done nothing like that I don't even know where to start.

Can anyone please suggest resources (tutorials, guides, paid or free) that explain practically how to get started with building embeddable JS widgets?

Thank you.

on May 14, 2020
  1. 2

    I just created a JS widget recently. It's surprisingly difficult to find any useful information on how to.

    But, I did find a tool called Zoid that helps. I believe it was created by PayPal for their embeddable checkout widgets.

    https://link.medium.com/KiyPEivBv6

    1. 1

      Interesting, did you build your JS widget with Zoid? Was it helpful? Does it require to pull in additional libraries on 3rd party sites? I am going to read the article - thank you.

      1. 2

        I actually didn't use Zoid because I finished building the widget before finding it. I basically just used an iframe and then a script that resizes it properly using iframe-resizer.

        But that method would not support popups very well. I believe Zoid does.

        Both methods require that you pull in libraries on 3rd party sites but you can make that easy by bundling it with webpack or something like that.

        This is what you would embed with the iFrame method.

        <iframe src="https://widget.event1.io/5c533f6284f0ee1e303bcf2b/speakers?showBio=false&showTitle=true&showWebsite=true&showImage=true" frameborder="0" sandbox="allow-scripts allow-top-navigation allow-modals allow-same-origin allow-forms allow-popups" id="e1--speakers-widget" style="display: block; min-width: 320px; width: 100%;"></iframe>
        <script>
          (function (w,d,s,o,f,js,fjs) {
              w['E1_Widget']=o;w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments) };
              js = d.createElement(s), fjs = d.getElementsByTagName(s)[0];
              js.id = o; js.src = f; js.async = 1; fjs.parentNode.insertBefore(js, fjs);
          }(window, document, 'script', 'e1', 'https://e1cdn.xyz/widget/v0.1.js'));
          e1('init', { widgetRef: '#e1--speakers-widget' });
        </script>
        
  2. 2

    first advice is to check if it does not already exist. if it doesn't you can browse "similar" projects on github for inspiration on how to structure it.

  3. 1

    I just wrote a cool integration snippet with my tool Story Creator.

    Basically it's a script you pull in and you get a function attached to the window object. You can pass args to the function and inside my app, I can process those args. When a video is rendered I return the rendered video URL in the callback.

    It's all dependant on what you're trying to achieve.

  4. 1

    I'm also interested