Skip to content

Ahmetaksungur/reading-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

readingTime.js

Calculate Reading Time for a Blog

View the Demo on CodePen →

Getting Started

Compiled and production-ready code can be found in the dist directory.

1. Include readingTime.js on your site.

Direct Download

You can download the files directly from GitHub.

<script src="dist/readingTime.min.js"></script>

CDN

<script src="https://unpkg.com/[email protected]/dist/readingTime.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/readingTime.min.js"></script>

NPM

npm i aks-reading-time

2. Initialize reading-time.js.

<div class="blog-content">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam luctus diam at nibh varius, a condimentum ante tristique. Integer ut tempor metus. Etiam fringilla auctor sapien ut fermentum.</p>
  <p>Fusce porttitor sit amet nisi eu tincidunt. Donec volutpat nunc in tempor mollis. Donec vehicula dignissim nisl, eget porta purus vestibulum vel.</p>
  <p>...</p>
</div>
<div class="result"></div>
const BlogReadingTime = new readingTime({
  read: ".blog-content", // text container in which reading speed will be measured
  result: ".result", // html element showing results
  speed: 1 // the number of words read per second
});

Options and Settings

const BlogReadingTime = new readingTime({
  read: ".blog-content",
  result: ".result",
  speed: 1,
  // other options
  secondText: 'Sec Read', // default value "Sec Read"
  minuteText: 'Min Read', // default value "Min Read"
  hourText: 'Hour Read', // default value "Hour Read"
  dayText: 'Day Read', // default value "Day Read"
});

License

The code is available under the MIT License.