# blockenberg/2.0.7/blocks/reading-time/frontend.js

Blockenberg — 600+ Advanced Gutenberg Blocks &amp; AI Agent for WordPress Block Editor, version 2.0.7. 23 lines.

- Page: https://pluginprobe.com/plugins/blockenberg/2.0.7/code/blocks/reading-time/frontend.js
- Raw: https://pluginprobe.com/plugins/blockenberg/2.0.7/raw/blocks/reading-time/frontend.js
- Modified: 2026-03-06T12:32:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/blockenberg/2.0.7/code/blocks/reading-time/frontend.js#L10-L20`.

```javascript
( function () {
  document.addEventListener('DOMContentLoaded', function () {
    var wraps = document.querySelectorAll('.bkrt-wrap[data-wpm]');
    if (!wraps.length) return;

    // Count words from the article/post content on the page
    var contentEl = document.querySelector('article .entry-content, .post-content, .wp-block-post-content, main article, .site-main .hentry, body');
    var rawText = contentEl ? contentEl.innerText || contentEl.textContent : document.body.innerText;
    var wordCount = rawText.trim().split(/\s+/).filter(Boolean).length;

    wraps.forEach(function (wrap) {
      var wpm    = parseInt(wrap.dataset.wpm, 10) || 200;
      var prefix = wrap.dataset.prefix || '';
      var suffix = wrap.dataset.suffix || 'min read';
      var mins   = Math.max(1, Math.ceil(wordCount / wpm));
      var textEl = wrap.querySelector('.bkrt-text');
      if (textEl) {
        textEl.textContent = (prefix ? prefix + ' ' : '') + mins + ' ' + suffix;
      }
    });
  });
}() );

```
