Home:ALL Converter>Which JavaScript library should I use for client-side hyphenation?

Which JavaScript library should I use for client-side hyphenation?

Ask Time:2013-06-03T03:07:18         Author:davidtheclark

Json Formatter

I would like to implement client-side hyphenation via JavaScript on some large texts on my site. (I know about CSS3 hyphenation and will use it instead when available, but it's usually not available.)

I have been using Hyphenator.js, and it works well but is very large (my optimized, compiled build with just English comes out to 106 KB) and pretty slow. It's large and slow enough that I'm considering dropping hyphenation altogether. It's just a luxury anyway.

But recently I came across what seems to be an alternative: Hypher. What baffles me is how Hypher can me so much smaller and do the same thing. I'm wondering if anybody can explain this.

Does Hypher work just as well? Is there any reason to use Hyphenator.js instead? Hypher's readme has a link to Hyphenator.js at the bottom of the page, but none of the text explains the connection between these projects.

Does anybody have an opinion about the most efficient client-side hyphenation?

Author:davidtheclark,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/16886258/which-javascript-library-should-i-use-for-client-side-hyphenation
Krisztián Balla :

I had a look at hyphenation in JavaScript and found the following four libraries:\n\n\nhy-phen: Is a pure JavaScript library developed by Yevhen Tiurin since 2016 using the MIT license. You are offered a JavaScript function that you can call to hyphenate strings. You only need to include the main JavaScript file and the desired language file to use it.\nHypher: Is a pure JavaScript library developed by Bram Stein since 2011 using the \"Three Clause BSD\" license. You are offered two JavaScript methods that you can call to hyphenate strings. It can only be installed using Node.js or jQuery.\nHyphenator.js: Is a JavaScript/HTML implementation developed by Mathias Nater since 2008 using the MIT license. The project is discontinued since 2018. It is not so simple to include into your project - you need to use the Merge&Pack tool first to create a JavaScript file that you can then include. It automatically scans the HTML page and adds hyphenation to selected HTML elements. There is no JavaScript function that you can call to manually hyphenate strings.\nHyphenopoly.js: Is the follow-up project of Hyphenator.js and developed since 2016 by Mathias Nater using the MIT license. It dropped some features of Hyphenator.js and is a bit simpler to use. Nevertheless it works the same way meaning there is no JavaScript function that you can call to manually hyphenate strings.\n\n\nAll four libraries are using the hyphenation algorithm developed by Franklin M. Liang that uses matching patterns to find hyphenation points in words. This algorithm does not provide 100% correct hyphenations as stated by Liang in his thesis:\n\n\n These patterns find 89% of the hyphens in a pocket dictionary word list, with essentially no error.\n",
2019-02-04T10:49:34
yy