All Projects → rstacruz → jquery.unorphan

rstacruz / jquery.unorphan

Licence: other
[deprecated] Obliterate text orphans.

Programming Languages

javascript
184084 projects - #8 most used programming language

Deprecated

See unorphan.js instead.


jQuery Unorphan

Obliterate text orphans.

$.unorphan() adjoins the last two words of any block of text to make sure that they will wrap together.

See Wikipedia for a description of text orphans.

Common usage

$(function() {
  $("p, li, h2, h3, h4, h5, h6").unorphan();
});

This changes:

<p>Apples, bananas and oranges.</p>

Into:

<p>Apples, bananas and&nbsp;oranges.</p>

Comparison to other utilities

Other similar utilities include:

As of time of writing, Unorphan works better than these because:

  • It does not mangle HTML at all (it operates on text nodes), you can be sure that your HTML tags will always be intact.

  • It does not rewrite innerHTML, causing your elements to unneededly reinitialize, and possibly losing events and data in the elements.

  • It's extremely small. (400 bytes)

  • It does the manipulation on the client side, making no impact to your in-page SEO efforts.

Acknowledgements

Original idea and implementation by Shawn Inman.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].