Blog (page 3)

Deferred; Promise with Resolvers

Promise.withResolvers is a new JavaScript spec that’s landing in a runtime near you soon if it hasn’t already. How is it useful? For example, let’s write an asynchronous function that returns your public IP address. We could return a Promise the old way: If you have experience with Promise you’ll know how quickly chaining them leads to […]

Private GitHub and JavaScript Imports

Are you using GitHub as a poor CDN? For example I could import my new VelociRouter project: The GitHub URL is even versioned using a git tag. However, is not a good CDN because it lacks appropriate cache headers and it serves code with a text/plain content type. Regardless, it’s still a useful place to publish […]

JSON Anything

Did you know that JSON.stringify and JSON.parse can take more than one argument? Perhaps like me you’ve done: To output readable JSON with 2 space formatting — the correctly amount of whitespace. But what is that null all about? Surely I’ve researched this before and forgotten. JSON basics Standard JSON values include the primitives: boolean null number string And then array and object collections […]

Just-in-Time JavaScript

Static site generators are cool but they require a build step. Frameworks like SvelteKit use Vite. For development, Vite basically does the build in the background. It caches and compiles to disk. It uses fancy tricks like hot module replacement to streamline the dev experience. Spicy. When it’s time to deploy to production there is a […]

Get in Line, Deno!

I’ve updated my Deno Tail Lines module to improve performance. See my original blog post for a quick intro. Reading a file backwards is trickier than it sounds! The Deno standard library has a new TextLineStream. This is a useful addition. However, If you only want the last ten lines, for example, you have to skip […]

XML Streamify

I’ve only gone and published an XML parsing library! It’s called XML Streamify on GitHub and it works like this: This example outputs blog post titles from my RSS feed. The parse function is an async generator in front of a custom TransformStream. parse will yield nodes as the XML document if fetched as parsed. This allows you to […]

The Final Off-Canvas Navigation: Revisited

So I may have used the word “final” rather ambitiously when I blogged “The Final Off-Canvas Navigation?” two years ago. At least I left the door open with a question mark? I’ve since made big changes to the implementation. The New (New) Version Checkout my new demo on CodePen. All the good stuff remains like focus state, keyboard […]

Buy me a coffee! Support me on Ko-fi