adding a manual reading time label is great for
user experience , but you can automate it w/ a tiny script. this snippet calculates the total word count and divides it by an average reading speed.
const wordsPerMinute = 200;const text = document.querySelector('#content').innerText;const wordCount = text.split(/\s+/).length;const readingTime = Math.ceil(wordCount / wordsPerMinute);console.log([code]~ ${readingTime} min read);[/code]
it makes your long-form guides feel much less
intimidating approachable. just make sure to target the right container so you dont count navigation links by accident ⚡ **always use a regular expression to handle extra whitespace lmao