Calculate Readablity & Reading Time Of Text - readability.js

Calculate Readablity & Reading Time Of Text - readability.js
File Size: 5.28 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Readability.js is a tiny jQuery plugin that predicts the difficulty level of your text and displays the reading level & estimated reading time of given articles or posts.

How to use it:

1. Put the readability.js script after the latest jQuery library (slim build is recommended).

<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/js/readability.js"></script>

2. Call the function readability on your text and display the estimated reading time.

<p id="text">
  ...
</p>
<div id="read-count-result"></div>
$("#text").readability(function(result){
  $("#read-count-result").html("Reading time is around <b>"+Math.ceil(result.time)+"</b> minutes");
});

3. Display the reading level of your text based on the Reading Ease Score.

<div id="read-difficulty"></div>
$("#text").readability(function(result){
  if(result.readingEase <= 15)
      difficulty = "Very Difficult"
  else if(result.readingEase <= 30)
      difficulty = "Difficult"
  else if(result.readingEase <= 60)
      difficulty = "Medium"
  else if(result.readingEase <= 80)
      difficulty = "Easy"
  else if(result.readingEase <= 100)
      difficulty = "Very Easy"
  $("#read-difficulty").html("This text is <b>"+difficulty+"</b>");
});

This awesome jQuery plugin is developed by dsheedes. For more Advanced Usages, please check the demo page or visit the official website.