npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

widowtamer-npm

v1.0.5

Published

Javascript to automatically fix typographic widows (actually orphans) on your web pages.

Downloads

25

Readme

(NOTE: Adding Nathon Ford's windowtamer script to NPM for my project.)

The Widow Tamer

…is a Javascript to automatically fix typographic widows on your web pages. It is designed to work with responsive sites, fixing widows as it finds them on resize or orientation change.

What is a Widow?

Widows are left over characters at the end of a paragraph. If the last line of a paragraph contains less than 14 characters (for example), it is said to have a widow. Widows are disruptive to both text layouts and reading experiences. Therefore, we must tame them.

How does The Widow Tamer work?

By setting the elements you want fixed, the number of characters you consider a “widow”, and the method by which you want them fixed, you can eliminate widows from your site. The script will cycle through the elements, apply your “method” (more on that later), check if the widow has been fixed, and repeat until the widow is tamed.

You only need to download the script, and link it in the HEAD of your page(s). Then, you can call a simple Javascript function to start taming widows:

wt.fix();

You can also set a few custom options:

Option Description Default

elements Which elements? jQuery-like Selector 'p,li,dd'

chars Number of characters to qualify a “widow” 14

method Method by which to fix the widow 'word-spacing' Options: 'word-spacing' 'padding-right/padding-left' 'letter-spacing' 'nbsp'

dir Used with certain methods. +/- change 'pos' Options: 'pos' 'neg'

event Any window events on which to run the fix 'orientationchange' Suggested Options: 'orientationchange' 'resize'

The script will run initially on window.onload, and then fire every time the 'event' is triggered.

Example Implementation

You can run multiple instances of the function target different elements with different methods. For example, here we are adding padding to the right of paragraphs in our main post article:

wt.fix({
elements: '#posts article p',
chars: 20,
method: 'padding-right',
event: 'resize'
});

And on the same page, on the same events, we may want to fix the headers in our footer by adding non-breaking spaces:

wt.fix({
elements: 'footer aside h1',
chars: 20,
method: 'nbsp',
event: 'resize'
});

Browser Support

The Widow Tamer works in IE8+ and all other modern browsers.

Details

The Widow Tamer was created by Nathan Ford. Feel free to interrupt him any time with questions, concerns, complaints, etc.

[email protected] @nathan_ford on Twitter