Skip to content

Instantly share code, notes, and snippets.

@felquis
Last active March 18, 2017 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felquis/e547ef0db08df8c453608de7e5a45c7d to your computer and use it in GitHub Desktop.
Save felquis/e547ef0db08df8c453608de7e5a45c7d to your computer and use it in GitHub Desktop.
How much time would I take to read a web page?
// output is in minutes
document.body.innerText.split(' ')
.filter((split) => split.length > 1)
.map((split) => split.replace(/[^a-zZ-a]+/g, ''))
.filter((split) => split.length > 1)
.reduce((acc, split) => {
const time = split.split('').length * 115
return [...acc, (time > 500) ? time : 500]
}, [])
.reduce((acc, time) => ([acc[0] + time]), [0])
.map((time) => (time / 1000 / 60))
// instead of using document.body, you can select only the main content of your page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment