微小 估计阅读时间jQuery插件 Reading Time.js

  • 源码大小:8.07KB
  • 所需积分:1积分
  • 源码编号:19JP-3326
  • 浏览次数:653次
  • 最后更新:2023年06月01日
  • 所属栏目:文本
本站默认解压密码:19jp.com 或 19jp_com

简介

你有没有想过人们花多长时间阅读你的博客文章?或者人们阅读你的产品描述需要多长时间?好吧,这就是这个插件的用途。

reading-time.js是一个小巧(缩小不到1kb)且易于使用的jQuery插件,可以帮助您指示用户将花费多少时间阅读您的内容。它将计算基于文本的内容帖子中的总字数,并根据特定的阅读速度在页面上显示估计的阅读时间(默认为每分钟250个单词)

如何使用它:

1.下载并放置主Javascriptjquery-读取时间.js加载最新的jQuery之后。

  1. <script src="/path/to/cdn/jquery.slim.min.js"></script>
  2. <script src="/path/to/js/jquery-reading-time.js"></script>

2.计算内容的预计阅读时间。

  1. <div id="post">
  2. ...
  3. </div>
  1. var rt = $('#post').readingTime();
  2. // =>
  3. {
  4. // Reading time in minutes (rounded)
  5. minutes: 1,
  6. // Reading time in seconds
  7. seconds: 49,
  8. // Reading time string "minutes:seconds"
  9. str: "00:49",
  10. // Word count (integer)
  11. words: 208
  12. }

3.覆盖默认的阅读速度(每分钟单词数)。

  1. var rt = $('#post').readingTime({
  2. WPM: 200,
  3. });

预览截图