calculateReadingTime - JavaScript Reading Time Estimator

calculateReadingTime is a lightweight and efficient JavaScript package designed to calculate the estimated reading time of any given text. This unique package dynamically adjusts based on font size and content length, making it ideal for blog posts, articles, and content-heavy websites.

How to Use calculateReadingTime

1. Include the CDN

To use this JavaScript reading time calculator, simply include the following CDN in your HTML file:

<script src="https://cdn.jsdelivr.net/gh/sumeetghimire/calculateReadingTime/index.js"></script>

2. Define Content for Reading Time Calculation

Wrap your text inside a container element for the reading time estimator:

<div id="content">
  <p>This is a sample text for reading time estimation.</p>
</div>

3. Display Reading Time

Create an element to display the calculated reading time dynamically:

<div id="reading-time"></div>

4. Implement JavaScript Function

Invoke the displayReadingTime function to calculate and display reading time in the target element:

<script>
  window.onload = function() {
    displayReadingTime('reading-time');
  }
</script>

Example Implementation

Complete JavaScript Reading Time Estimator Code:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Reading Time Test</title>
        <script src="https://cdn.jsdelivr.net/gh/sumeetghimire/calculateReadingTime/index.js"></script>
  </head>
  <body>
    <div id="content">
      <p>This text demonstrates how to calculate reading time dynamically using JavaScript.</p>
    </div>
    <div id="reading-time"></div>
    <script>
      window.onload = function() {
        displayReadingTime('reading-time');
      }
    </script>
  </body>
</html>

Why Use calculateReadingTime?

License

This JavaScript reading time calculator is open-source and licensed under the MIT License.