Blog (page 3)

SVG Icons with CSS Masks

Have you ever inlined SVG icons inside a CSS stylesheet? It can improve performance by reducing HTTP requests if done selectively. I do this all the time using a custom property and background-image to make reusable icons. One downside is the inability to change or transition colours easily. I’ve recently discovered a new technique that solves this […]

Buy Me a Coffee!

I’m trying something new this year. In exchange for over a decade of continued blogging and open source content I’m asking for a little something in return. Head over to ko-fi.com/dbushell and show support with a small tip. Tipping is entirely optional, of course! This blog will remain free. I don’t believe adding a hard […]

New Projects for 2024!

Happy New Year! I had free time at the end of 2023. One idea led to another and I ended up writing a new JavaScript web framework. Just what the Internet needs! The first project is a little smaller in scope: VelociRouter VelociRouter is a JavaScript HTTP router inspired by Polka and Hono. It takes a Request and […]

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, raw.githubusercontent.com 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 […]

Buy me a coffee! Support me on Ko-fi