Promises Tutorials

  • By
    How to Detect Failed Requests via Web Extensions

    One of the best things that ever happened to t he user experience of the web has been web extensions. Browsers are powerful but extensions bring a new level of functionality. Whether it's crypto wallets, media players, or other popular plugins, web extensions have...

  • By
    JavaScript waitFor Polling

    As more of the JavaScript developers write becomes asynchronous, it's only natural to need to wait for conditions to be met. This is especially true in a world with asynchronous testing of conditions which don't provide an explicit await. I've written about waitForever, waitForTime...

  • By
    queryLocalFonts

    One of the larger downloads when requesting a webpage are custom fonts. There are many great techniques for lazy loading fonts to improve performance for those on poor connections. By getting insight into what fonts the user has available, we can avoid loading custom fonts.

  • By
    Detect the Content Type in the Clipboard

    A user's clipboard is a "catch all" between the operating system and the apps employed on it. When you use a web browser, you can highlight text or right-click an image and select "Copy Image". That made me think about how developers can detect what is...

  • By
    fetch with Timeout

    A few years back I wrote a blog post about how write a fetch Promise that times out. The function was effective but the code wasn't great, mostly because AbortController , which allows you to cancel a fetch Promise, did not yet exist. With...

  • By
    How to Determine a JavaScript Promise’s Status

    Promises have changed the landscape of JavaScript. Many old APIs have been reincarnated to use Promises (XHR to fetch, Battery API), while new APIs trend toward Promises. Developers can use async/await to handle promises, or then/catch/finally with callbacks, but what Promises don't tell...

  • By
    Detecting Fonts Ready

    Knowing when resources are loaded is a key part of building functional, elegant websites. We're used to using the DOMContentLoaded event (commonly referred to as "domready") but did you know there's an event that tells you when all fonts have loaded? Let's learn how...

  • By
    How to Use Storage in Web Extensions

    Working on a web extension is an interesting experience -- you get to taste web while working with special extension APIs. One such API is storage -- the web extension flavor of persistence. Let's explore how you can use session and local storage within...

  • By
    navigator.clipboard API

    Reading from and writing to the user's clipboard can be both a very useful and dangerous capability. Used correctly and it's a huge convenience to the user; used dubiously and the user could suffer catastrophic consequences. Imagine a wrong account number or wallet address...

  • By
    JavaScript Wake Lock API

    An enjoyable web apps rely on engineers implementing the APIs that cover all of the small things. Those small things sometimes improve performance, usability, accessibility, and the app's relationship with its host system. The Wake Lock API is the latter -- an API...