Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Paul Campbell — A Modern Approach to Third-Part...

Paul Campbell — A Modern Approach to Third-Party Embedded Widgets (Turing Fest 2018)

Embeddable widgets have proliferated the web since JavaScript was born in the mid-nineties, and even before. Since the days of CGI counters, we have come a long way, with companies like Intercom and Stripe providing drop-in code to render components that provide rich and interactive experiences within customers’ existing sites.

At Tito, we have provided an embeddable widget since early on. When it came to rewriting it, we wanted to keep the things that made it great: a simple drop-in native-like web component that was easy to customise with CSS and integrate with JavaScript hooks. Our secondary goals were higher level. We wanted an easy to use codebase, and a widget that could be the primary code that we used on our own checkout pages. We also wanted to hook in to the modern ecosystem of JavaScript package managers, bundlers and modules.

This talk will explore the process of upgrading an older widget to a modern codebase and framework, some of the advantages to be gained, and some of the challenges faced.

Turing Fest

August 02, 2018
Tweet

More Decks by Turing Fest

Other Decks in Programming

Transcript

  1. Patterns • HTML element to fill/replace • Optionally, set up

    a queue • Global or inline tags for config • Insert additional <script> before the first <script> tag
  2. Pros & Cons • Pros • Simple • Use modern

    JavaScript features, with limited fallbacks • Dead easy to get started • Control • 2kb filesize • Cons • No bundling • Can get out of hand quickly
  3. Pros & Cons • Pros • Split code into logical

    components • Use modern JavaScript features • Dependency management • Cons • Complexity of setup • 145kb filesize
  4. Pros & Cons • Pros • All the benefits of

    modular approach • Rapid development • Rich ecosystem • “Easy” to add validations, routes, transitions etc. & more • Cons • Complexity of setup • Bloat, bloat and more bloat • 450kb filesize