Sign in

Alex MacArthur

@macarthur.me
29 followers 21 following 106 posts

Bossing around computers in made-up languages.

PostsRepliesMedia
Alex MacArthur @macarthur.me · 30/03/2026
In the midst of JamComments updates, I had the chance to experiment with a number of ways to preload images in JavaScript. Wrote 'em up here: macarthur.me/posts/preloa...
macarthur.me
Your options for preloading images with JavaScript
There are a number of ways to preload an image on demand with JavaScript — each with their own strengths & drawbacks. Let's explore them.
000
Alex MacArthur @macarthur.me · 11/11/2025
I wrote about DNS resolution from the POV of a browser, and how you can fine-tune the process to squeeze out some performance points. Check it: macarthur.me/posts/dns/
macarthur.me
DNS Resolution Adds Up
DNS resolution is cheap, but it ain't free. In scenarios when it counts, the `dns-prefetch` resource hint could give you a nice, slight edge in the front-end performance game.
000
Alex MacArthur @macarthur.me · 18/06/2025
He’s right. This place will continue to lose if it keeps operating like this.
000
Alex MacArthur @macarthur.me · 02/06/2025
I have learned first-hand that the document.currentScript can be useful. #javascript macarthur.me/posts/curren...
macarthur.me
`document.currentScript` is more useful than I thought.
After discovering and being unsure of its value, I just realized how useful `document.currentScript` can be in exposing configuration properties to `<script>` elements (and other things too).
020
Alex MacArthur @macarthur.me · 12/05/2025
I’ve been spending some dedicated time tinkering w/ iterators, iterables, & generators in #JavaScript. I’m still struggling a bit to find use cases in which it’s materially the best solution. But! I am liking the ergonomics more. Blog post: macarthur.me/posts/genera...
macarthur.me
I think the ergonomics of generators is growing on me.
I took a stab at getting more familiar with iterators, iterables, and generators. I think I'm starting to like the ergonomics.
031
Alex MacArthur @macarthur.me · 15/04/2025
Sickkk new feature coming to PicPerf: automatic resizing. Here's how it'll work: - Behind the scenes, PP will headlessly render your page at a large desktop's screen dimensions.
100
Alex MacArthur @macarthur.me · 31/03/2025
I learned about “forbidden” request headers recently, which can’t be overridden by client-side JavaScript APIs. A subset also give some nice context about a request, like whether it came from someone directly navigating to a page. Useful stuff. Wrote more here: macarthur.me/posts/forbid...
macarthur.me
I guess some request headers are more trustworthy than others.
There's a subset of request headers that can't be modified by a spec-compliant user agent. Let's explore why they're useful for determining how and for what purpose a request was triggered.
000
Alex MacArthur @macarthur.me · 11/02/2025
I think we’re over-indexing on the importance of time-to-ship and the AI tooling that minimizes it. Shipping is easier, but committing to iterating on & growing a product is still hard. That’ll probably continue to be the differentiating factor between success & failure.
000
Alex MacArthur @macarthur.me · 10/02/2025
TIL about “forbidden” request headers. None of these can be set in the browser by JavaScript APIs like fetch() or XMLHttpRequest.
list of forbidden request headers
021
Reposted by Alex MacArthur
Barry Pollard @tunetheweb.com · 08/02/2025
Good post from @macarthur.me on the various ways to break up long tasks. macarthur.me/posts/long-t... I especially like nice summary at the bottom:
How Do I Choose?

The approaches we've covered here are not exhaustive, but I think they do a good job at representing the various trade-offs you should consider when breaking up long tasks. Still, depending on the need, I'd probably only reach for a subset of these myself.

If I can do the work off from the main thread, I'd choose a web worker, hands-down. They're very well supported across browsers, and their entire purpose is to offload work from the main thread. The only downside is their clunky API, but that's eased by tools like Workerize and Vite's built-in worker imports.

If I need a dead-simple way to break up tasks, I'd go for scheduler.yield(). I don't love how I'd also need to polyfill it for non-Chromium users, but the majority of people would benefit from it, so I'm up for that extra bit of baggage.

If I need very fine-grained control over how chunked work is prioritized, scheduler.postTask() would be my choice. It's impressive how deep you can go in tailoring that thing to your needs. Priority control, delays, cancelling tasks, and more are all included in this API, even if, like .yield(), it needs to be polyfilled for now.

If browser support and reliability are of the utmost importance, I'd just choose setTimeout(). It's a legend that's not going anywhere, even as flashy alternatives hit the scene.
1134
Alex MacArthur @macarthur.me · 03/02/2025
If you’ve ever needed to break up a long JavaScript task to keep the UI responsive, you’ve probably reached for setTimeout(). Turns out there are a boatload of other options at your disposal, like scheduler.yield(). I wrote about a handful & their tradeoffs:
scheduler.yield() example
131
Alex MacArthur @macarthur.me · 25/01/2025
Look at what you'll soon be able to do in native CSS (currently supported in Chromium browsers):
You can now opt into animating intrinsic size keywords by using "interpolate-size: allowed-keywords" on a parent element.
110
Alex MacArthur @macarthur.me · 18/01/2025
Short post about composing template literal types in TypeScript: macarthur.me/posts/templa...
macarthur.me
I didn't know you could compose template literal types in TypeScript.
TypeScript's string literal types are a lot more useful than I originally thought.
021
Alex MacArthur @macarthur.me · 14/01/2025
I wrote about using short-lived memoization bound to a single tick of the event loop in JavaScript. queueMicrotask() is awesome. Read: macarthur.me/posts/memoiz...
macarthur.me
Short-Lived, Tick-Bound Memoization in JavaScript
Sometimes, typical memoization function won't cut it when there are so many changing variables in play between ticks of the event loop. Let's explore how we might fine-tune it.
020
Alex MacArthur @macarthur.me · 06/01/2025
I blabbed a ton about forced DOM reflows, the event loop, and the browser’s repaint cycle, just to slide open a box with CSS transitions & JavaScript. Look: macarthur.me/posts/box
macarthur.me
Using Forced Reflows, the Event Loop, and the Repaint Cycle to Slide Open a Box
Triggering smooth, reliable CSS transitions with JavaScript can be weirdly more complicated than you expect. We're gonna explore it more.
010
Alex MacArthur @macarthur.me · 05/12/2024
Comment submissions for JamComments just got a big speed boost because I finally remembered to set Laravel’s QUEUE_CONNECTION to something other than “sync.” 🤦‍♂️
010
Alex MacArthur @macarthur.me · 02/12/2024
I’ve been learning about content security policies and have reached the following conclusion: They’re valuable even for simple blogs and very easy to set up. You should probably just get one. macarthur.me/posts/csp
macarthur.me
You Might As Well Use a Content Security Policy
Content Security Policies, even for simple, content-focused sites, offer good protection against rare but real vulnerabilities out there. You might as well just get one.
000
Alex MacArthur @macarthur.me · 02/12/2024
My first (personal) M series MacBook is coming this week. I’ve been doing all dev work on a 2015 MBP until now and I’m so ready to enter the future.
000
Alex MacArthur @macarthur.me · 01/12/2024
Simple demo for embedding JamComments client-side: - ~10 lines of code to configure - no custom styles necessary - ~2.6kb (gzipped) of JavaScript needed to load - ~3.6kb of HTML to load lazily load in after that And none of the grossness other comment tools throw in. jamcomments.com/demo/vanilla
010
Alex MacArthur @macarthur.me · 30/11/2024
My daughters are starting their first entrepreneurial endeavor. Introducing the Bin Buddies! binbuddies.pro
binbuddies.pro
Let the Bin Buddies roll out your bins for you!
We'll take out your trash & recycling bins for you every week, so you don't have to keep forgetting about it!
000
Alex MacArthur @macarthur.me · 29/11/2024
You can now embed comments on your website entirely client-side. Very similar to how some other services work, but with a waaaaaaaaaay smaller performance penalty and far less grossness. jamcomments.com/docs/integra...
jamcomments.com
Vanilla JavaScript
000
Alex MacArthur @macarthur.me · 24/11/2024
JamComments.com is about to become very CSP-friendly. And as a result, it’ll be very difficult to tell you’re using a third-party service, even by looking through the page source. 🥷
jamcomments.com
JamComments: A guilt-free comment service for your blog.
A blog comment service and Disqus alternative that won't leave you feeling like you missed a shower.
000
Alex MacArthur @macarthur.me · 22/11/2024
Crazy how we’ve all just forgotten about the fact that there’s a map on the back of the Declaration of Independence.
010
Alex MacArthur @macarthur.me · 22/11/2024
What a friggin week. Never touching a database again.
010
Alex MacArthur @macarthur.me · 20/11/2024
Small blog post on running a Chrome extension's content scripts in a way that won't cause a review delay: picperf.io/posts/chrome...
picperf.io
Avoiding a "Host Permission" Review Delay When Publishing a Chrome Extension
Get a Chrome extension reviewed a smidge more quickly by more carefully executing its client-side scripts only when they're needed.
000
Alex MacArthur @macarthur.me · 18/11/2024
Of course.
000
Alex MacArthur @macarthur.me · 18/11/2024
Early version of the PicPerf Image Saver extension is out. Plz try it! It lets you download any WebP or AVIF as a more useful JPEG, PNG, or GIF. Got it submitted to the Chrome Web Store, but you can install the unpacked version now.
100
Alex MacArthur @macarthur.me · 15/11/2024
I’m proud of how PicPerf’s page analyzer is built. It uses Bun, Puppeteer, and Laravel to collect *only* the images that’d be downloaded when a user scrolls down a page on a phone, before running an optimization analysis on each one. Wrote about wiring it up: picperf.io/posts/collec...
picperf.io
Collect All Requested Images on a Website Using Puppeteer
Walking through how I used Puppeteer to programmatically collect every image loaded when a page is viewed in the browser.
000
Alex MacArthur @macarthur.me · 11/11/2024
Jira tickets: Pagan: “As a user,” Saintly: “As a child of the Living God,”
000
Alex MacArthur @macarthur.me · 09/11/2024
Found out a few weeks ago that React's `dangerouslySetInnerHTML` prop is more dangerous than I thought — inline event handlers on injected HTML still fire! Easy enough to neutralize, though. A short post about it. #javascript #reactjs macarthur.me/posts/safer-...
macarthur.me
Make dangerouslySetInnerHTML Safer by Disabling Inline Event Handlers
Even though it won't run <script> tags, React's dangerouslySetInnerHTML still allows inline event handlers to execute. Here's how you might neutralize that threat.
030
Alex MacArthur @macarthur.me · 08/11/2024
macarthur.me/scraps/footp...
macarthur.me
Unseen Footprints
Sometimes I feel like I’ve been holding my breath for a long time and I'm not sure there will be any air to breathe when I finally let go. It’d be nice to know what God is doing in those moments rathe...
010
Alex MacArthur @macarthur.me · 31/10/2024
I've published a first version of my policy on AI for my website. It's likely shift a bit over time, but I don't see the spirit of it ever changing. macarthur.me/ai
macarthur.me
AI will not write for me.
Why I've committed to never allowing AI to articulate an idea on my behalf.
000
Alex MacArthur @macarthur.me · 31/10/2024
ChatGPT is the 4th most largest referrer to TypeIt’s site right now. Kinda crazy.
000
Alex MacArthur @macarthur.me · 25/10/2024
Quick demo on using TypeIt and React to create a text streaming animation like ChatGPT: macarthur.me/posts/stream...
macarthur.me
Streaming Text Like an LLM with TypeIt (and React)
We're getting real familiar with seeing LLMs stream chunks of text to a page. Here's a simple demonstration of how you'd mimic the effect with TypeIt.
000
Alex MacArthur @macarthur.me · 22/10/2024
macarthur.me/scraps/control
macarthur.me
Control
It is pathetic how often I overestimate the control I have over my circumstances, and how protective I am of the little I do have. A couple passages have been stirring this up. First, from Exodus. The...
000
Alex MacArthur @macarthur.me · 20/10/2024
Introduced domain settings for PicPerf.io. To start, you can set a max image width for optimizations. No more worrying about accidentally making your visitors download a hero image 5k pixels wide (more common than you might think!). #webperf
000
Alex MacArthur @macarthur.me · 12/10/2024
Didn’t know until recently that you could use adjacent parameters as default values in functions & classes in JavaScript. Post about it: macarthur.me/posts/siblin...
macarthur.me
I didn't know you could use sibling parameters as default values in functions.
Default parameter values have been in JavaScript for a while. But I just found out you can use sibling parameters as the default values themselves.
000
Alex MacArthur @macarthur.me · 16/09/2024
macarthur.me/scraps/whirl...
macarthur.me
Whirlwind
I’ve either never seen this verse or I’m reading it with different eyes: “Though he slay me, I will hope in him; yet I will argue my ways to his face.” - Job‬ ‭13‬: ‭15‬ ‭ESV‬‬What a weird combination...
000
Alex MacArthur @macarthur.me · 10/09/2024
macarthur.me/scraps/being...
macarthur.me
Being Still
I have not been reading Psalm 46: 10 correctly for a long time (probably because I’ve always read it in isolation). “Be still, and know that I am God.”I’ve always taken “stillness” to strictly be a sy...
000
Alex MacArthur @macarthur.me · 23/08/2024
It's in your best interest to use animated WebPs instead of GIFs on your website. More words about it: picperf.io/posts/gif-to...
picperf.io
It Might Be Worth Converting that GIF to an Animated WebP
The animated GIF has become a key piece of today’s meme culture, despite being around decades prior. But there are serious technical advantages to
000
Alex MacArthur @macarthur.me · 14/08/2024
AI-powered moderation in JamComments is a go! Rather than auto-approving everything (risky), or manually doing it yourself (a hassle), set a prompt and an LLM (or a small man in a box - who knows) will handle it. Real easy to set up.
000
Alex MacArthur @macarthur.me · 12/08/2024
PicPerf’s over here converting 8,000px-wide images to AVIF without whining about it. Such a diligent little workhorse.
000
Alex MacArthur @macarthur.me · 11/08/2024
Wrote a blog post on native JavaScript decorators for Frontend Masters. Read it! frontendmasters.com/blog/explori...
frontendmasters.com
Exploring the Possibilities of Native JavaScript Decorators – Frontend Masters Boost
Native support for decorators is inevitable! It simplifies augmenting class methods, which can help with things like logging, memoization, debouncing, and dependency injection.
000
Alex MacArthur @macarthur.me · 06/08/2024
I've been tinkering with native JavaScript decorators for the past few weeks, and became obsessed with one use case: dependency injection. In all that tinkering, I ended up building a small framework around it. Here’s Power Plant: github.com/alexmacarthu...
github.com
GitHub - alexmacarthur/power-plant: A dependency injection framework built on native decorators.
A dependency injection framework built on native decorators. - alexmacarthur/power-plant
000
Alex MacArthur @macarthur.me · 01/08/2024
Check this out - an IoC container/dependency injection framework using native JavaScript decorators in 25 lines of code.
000
Alex MacArthur @macarthur.me · 29/07/2024
Self-hosting Plausible Analytics without automated backups can keep you up at night, and it is a well-established fact that poor sleep may lead to you dying. To help, I wrote this guide on setting them up with an S3/R2 bucket and a little cron job: plausiblebootstrapper.com/posts/back-u...
plausiblebootstrapper.com
How to Back Up Self-Hosted Plausible Analytics Data to an R2 or S3 Bucket
Services like S3 and R2 can be invaluable when self-hosting Plausible Analytics. Let's walk through what it looks like to use them for automated backups a simple cron job.
000
Alex MacArthur @macarthur.me · 27/07/2024
I wrote a short post on using client-side JavaScript to built structured data. macarthur.me/posts/struct...
macarthur.me
On Building Structured Data with Client-Side JavaScript
Thinking through some of the trade-offs and benefits in using client-side JavaScript to generate structured data.
110
Alex MacArthur @macarthur.me · 22/07/2024
A small JamComments.com update has been rolled out to all integrations. You can now customize many of the bits of microcopy throughout the UI, rather than going w/ the standard, out-of-the-box stuff. To help you picture this concept, I made you this picture.
010
Alex MacArthur @macarthur.me · 09/07/2024
You can now retrieve all your comments from JamComments via REST API. 🎉 Should allow you to get pretty creative in how you surface them across your site. #jamstack jamcomments.com/docs/api
jamcomments.com
The REST API
The REST API allows you to fetch comments as a paginated JSON list.
000
Alex MacArthur @macarthur.me · 06/07/2024
Serneke Bostad - a Swedish homebuilding company - is using PicPerf to optimize over 2,700 images. Average size reduction: ~94%. 🤯 #webperf #seo #performance
000