Posts in category: "javascript"

How to use Puppeteer in a Netlify (AWS Lambda) function

I recently gave a talk at JAMstack_conf San Francisco about how I used headless chrome (via Puppeteer) and Cloudinary to capture screenshots of my interactive caniuse embed. I did this to have a fallback image to use in case the embed couldn’t be loaded, for example in cases...

Removing duplicate objects from an Array (is hard)

Let’s say we have an array of objects such as the following: const books = [ { name: "My Sister the Serial Killer", author: "Oyinkan Braithwaite" }, { name: "Educated", author: "Tara Westover" }, { name: "My Sister the Serial Killer", author: "Oyinkan Braithwaite"...

What self.skipWaiting() does to the service worker lifecycle

The ServiceWorker.skipWaiting() method is a life saver. It ensures that any new versions of a service worker will take over the page and become activated immediately. To understand why this is so important and useful, we need to revisit the service worker lifecycle. I have a more detailed article...

What is tree shaking and how does it work?

When Javascript applications get to a certain size, it’s helpful to separate the code into modules. However, when we do so, we can end up with code imported that isn’t actually used. Tree shaking is a method of optimising our code bundles by eliminating any code from the...

Understanding the Virtual DOM

I’ve recently been writing about what exactly the DOM and the shadow DOM are and how they differ. To recap, the Document Object Model is an object-based representation of an HTML document and an interface to manipulating that object. The shadow DOM can be thought of as a “lite”...