A Tiny JavaScript Helper for Reading Time
Reading-time estimates are simple arithmetic dressed up as a feature. Here is the whole thing, small enough to paste anywhere.
Constraints are underrated. A fixed word count, a single typeface, or a two-colour palette forces decisions that an open brief lets you postpone forever.
export function readingTime(text, wpm = 200) {
const words = text
.replace(/<[^>]+>/g, ' ')
.trim()
.split(/\s+/)
.filter(Boolean).length;
return Math.max(1, Math.ceil(words / wpm));
}
const minutes = readingTime(document.querySelector('article').innerHTML);
console.log(`${minutes} min read`);
Every studio accumulates habits it never chose. Once a year we list them and ask whether each one still earns its place.
We schedule unstructured time on purpose. Some of our best ideas started as an afternoon with no plan and a stack of old magazines.
Feedback lands better when it describes the effect rather than the fix. “I lost track here” is more useful than “move this paragraph”.
Related posts
Shell Aliases That Save Us an Hour a Week
Git, rsync, and image tools, shortened to a few keystrokes.
Writing a Clean WordPress Shortcode
Attributes, escaping, and output buffering done the boring way.
A Small Go Server for Static Previews
Serve a folder, add caching headers, and ship a single binary.
Comments · 10
I tried this on a client project last month and it saved us at least two review rounds.
Portra 400 for most of them, and one roll of HP5 for the evening shots.
Yes! Same experience here.
I tried this on a client project last month and it saved us at least two review rounds.
Great list. Adding two of these to my reading pile right now.
We adopted the no-email-before-ten rule after your last post. Our mornings are so much calmer.
We adopted the no-email-before-ten rule after your last post. Our mornings are so much calmer.
Glad it helped. The second pass is where it really clicks.
Do you have a recommendation for someone just starting out? Everything I find assumes years of experience.
Thank you for including the code. I adapted it for our docs site in about ten minutes.