You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[helpers] CSS and JavaScript content inflates reading time #1077
The reading-time helper counts CSS and JavaScript inside HTML <style> and <script> elements as article words. Posts containing self-contained interactive embeds can therefore show substantially inflated reading times even though readers never see that code.
The word counter removes the opening and closing HTML tags, but retains their contents. This also counts comments inside those elements.
To Reproduce
Source-level reproduction against SDK commit 7c83d1ffb6e6961a8d8cb5dfba81fa62ff47cb51:
Copy count-words.js, count-images.js and reading-minutes.js from packages/helpers/lib/utils/ into a temporary directory.
Give the copies .mjs extensions and update the two relative imports in reading-minutes.mjs to include .mjs. No counting logic needs changing.
Save the following as repro.mjs in that directory and run node repro.mjs:
Expected: all three inputs contain the same 275 visible words and should produce the same one-minute estimate. The contents of executable script and stylesheet elements should be excluded. Visible code samples in <pre> or <code> should still count.
Technical details
Affected package: @tryghost/helpers; the package manifest at the tested revision reports version 1.1.107.
Activity