为什么使用SVG核心设置Fontawesome默认情况下禁用这些选项?

发布于 2025-01-24 04:30:28 字数 991 浏览 2 评论 0原文

我正在尝试使我的 fontawesome 6 通过导入我使用的几个单独的图标而不是我使用的几个单独的图标,而不是安装更轻量级整个样式,通过我的Web应用程序的npm构建过程。文档似乎说做到这一点是通过安装@fortawesome/fontawesome-svg-core (然后大概是一个图标包,例如@fortawesome/fortawesome/fore-solid-svg-icons,尽管文档中未明确提及)。

以这种方式使用fontawesome 默认情况下禁用标准Fontawesome配置的以下功能:

  • < svg>

    自动替换< i>
  • 观看图标更改的页面

内容,文档的另一部分 A>表明禁用的特定选项为AutorePlaceSvgobservemutations

默认情况下,以这种方式配置fontawesome的原因是什么,并且重新实现它们(性能或其他方式)是否有任何不利条件?

I'm trying to make my FontAwesome 6 installation more lightweight by importing the few individual icons I'm using instead of a whole style, via my web app's npm build process. The documentation seems to say that the way to do this is by installing @fortawesome/fontawesome-svg-core (and then presumably an icon pack like @fortawesome/free-solid-svg-icons, although not explicitly mentioned in the docs).

Using FontAwesome in this way disables by default the following capabilities of the standard FontAwesome configuration:

  • Automatically replaces <i> tags with <svg>

  • Watches the page for icon changes and additions

Going deeper into this, another section of the docs shows that the specific options disabled are autoReplaceSvg and observeMutations.

What are the reason(s) that configuring FontAwesome in this way disables these options by default, and is there any disadvantage to re-enabling them, either performance or otherwise?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北方的巷 2025-01-31 04:30:28

大约一天之后,我在另一部分 (非常广泛的)文档:

我们的基本包(@fortawesome/fontawesome-free和
@fortawesome/fontawesome-pro)针对的是那些想要的人
快速将字体纳入他们的项目,但不想
花费时间和精力来了解
兜帽。因此,许多行为都是自动的,并且有效
没有任何干预。

相比之下,Fontawesome-SVG-core套件适用于更专业的
情况或用于形成基础API为其他组件供电
或库。实际上,我们自己的Vue官方组成部分,反应,
Ember和Angular都使用Fontawesome-SVG核包装
引擎盖。

因为这个核心包和图标内容软件包避免
做任何自动的事情或创造副作用
与他们开发难以控制或理性。

A day or so later, I found this by chance in another section of the (very extensive) documentation:

Our Basic packages (@fortawesome/fontawesome-free and
@fortawesome/fontawesome-pro) are aimed at individuals who would like
to quickly integrate Font Awesome into their projects but do not want
to invest the time and effort to understand what's going on under the
hood. For this reason a lot of the behavior is automatic and works
without any intervention.

In contrast, the fontawesome-svg-core package is for more specialized
situations or for forming the underlying API to power other components
or libraries. In fact, our own official components for Vue, React,
Ember, and Angular all use the fontawesome-svg-core package under the
hood.

Because of this the core package and the icon content packages avoid
doing anything automatic or creating side-effects that make
development with them difficult to control or reason.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文