Lightweight configurable JS tool to remove widows from dynamic text.
Table of Contents
npm i widow-js
Good use case: Removing widows from dynamics text for which you don't control.
Not so good use case: Remove widows from static site for which you are too lazy to remove yourself. But you know... no judgement here 🤷🏻♂️
How to use
import Widow from 'widow-js';
Initializing will automatically remove widows with your options.
const widow = new Widow;
If you need to remove widows from more elements later, use the removeWidowedElements method. Note: Widow will cache elements already transformed previously to avoid extra words wrapping.
If you'd like to remove widows from a string use the removeWidowedText method
Here's how you would use removeWidowedText in the context of a react app
If your words prop is greater than the number of words in an element, Widow will skip element.
||Number value > 1|
||A DOMString containing one or more selectors to match against|
||Turn on/off warnings|
Please open an issue for support.