Read time calulator
by Sam Wray
HTML
<textarea>
Photo booth lumbersexual blog mlkshk distillery. Marfa kogi pickled wolf. Pickled butcher VHS wolf. Williamsburg viral American Apparel slow-carb. Fashion axe church-key PBR&B, Intelligentsia chambray deep v retro. Trust fund occupy tofu wayfarers, Odd Future bespoke small batch shabby chic. Post-ironic jean shorts asymmetrical, chia kale chips normcore butcher church-key master cleanse leggings raw denim.
Try-hard Williamsburg whatever, crucifix farm-to-table mlkshk Carles aesthetic. Chillwave pickled lo-fi, gastropub Schlitz tofu vinyl next level butcher High Life mustache quinoa farm-to-table 90's narwhal. Bitters before they sold out small batch chia. Bushwick iPhone McSweeney's chambray art party tousled. Umami taxidermy pickled Blue Bottle semiotics keffiyeh. Meh distillery fingerstache tilde. Marfa literally wolf, ennui 90's gluten-free kitsch distillery Blue Bottle VHS.
</textarea>
<div></div>
JavaScript
var $ = document,
txtarea = $.getElementsByTagName('textarea')[0],
minutesDiv = $.getElementsByTagName('div')[0];
function calcReadMinutes(inputWords) {
var words = inputWords.trim().split(" "),
noWords = words.length;
// Average WPM is 200-250
var speed = Math.floor(Math.random() * (250 - 200 + 1)) + 200;
return noWords / speed;
}
txtarea.addEventListener('input', function() {
var minutes = calcReadMinutes(this.value);
minutes = Math.floor(minutes);
if(minutes < 1) minutesDiv.textContent = '< 1';
else if(minutes > 60) minutesDiv.textContent = '> 60';
else minutesDiv.textContent = minutes;
});