客户端连字符应使用哪个JavaScript库? [英] Which JavaScript library should I use for client-side hyphenation?

查看:50
本文介绍了客户端连字符应使用哪个JavaScript库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过JavaScript在网站上的一些大文本上实现客户端连字符.(我知道CSS3连字,并会在可用时使用它,但通常不可用.)

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.)

我一直在使用 Hyphenator.js ,它可以正常工作,但体积很大(我优化了,仅英语版本的编译版本就达到了106 KB),而且速度很慢.它足够大且很慢,因此我考虑完全放弃连字符.无论如何,这只是一种奢侈.

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.

但是最近我遇到了一种替代方法: Hypher .令我感到困惑的是,Hypher如何让我这么小并做同样的事情.我想知道是否有人可以解释这一点.

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.

Hypher是否也能正常工作?有什么理由要改用Hyphenator.js吗?Hypher的自述文件在页面底部具有指向Hyphenator.js 的链接,但没有一个文字说明了这些项目之间的联系.

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?

推荐答案

相对而言,Hypher之所以这么小,主要是因为它依赖外部加载的jQuery进行页面集成.Hyphenator.js是完全独立的,因此必须包含更多样板,以便在浏览器中操纵HTML.(他们甚至重新实现了一些jQuery功能.)

The primary reason Hypher's so small, comparatively, is that it relies on an externally-loaded jQuery for page integration. Hyphenator.js is completely standalone and thus has to include way more boilerplate for manipulating HTML across browsers. (They even re-implement some jQuery functionality.)

说句公道话,Hyphenator.js是一个相对较旧的项目,为了充分利用浏览器的改进功能,还没有完全对其进行重写.(请注意,他们很自豪地支持Firefox 3.0.)而且,更慈善的是,Hyphenator.js还有很多精细的设置.

To be fair, Hyphenator.js is a relatively old project that hasn't been completely rewritten along the way to take advantage of substantial browser improvements. (Note that they proudly support Firefox 3.0.) And, more charitably, Hyphenator.js has many more finely-grained settings.

如果您已经在使用jQuery,并且没有使用Hyphenator.js的高级API,则切换到Hypher可能是值得进行的改进.

If you're already using jQuery, and don't use Hyphenator.js's advanced API, switching to Hypher may be a worthwhile improvement.

这篇关于客户端连字符应使用哪个JavaScript库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆