SVG JavaScript Core
We provide more advanced packages that are suitable for more specialized situations. These packages are side-effect free and provide no automatic replacement of
<i>
tags to<svg>
tags. (Although it can still be used throughdom.watch()
).
When should you reach for this bad boy?
The SVG core package is helpful and recommended in the following cases:
- to subset a large number of icons into only the icons that you are using
- as base libraries for larger integrations with tools like React, Angular, Vue, or Ember (in fact our own components use these packages)
- as CommonJS/ES6 Modules bundling tool like Webpack, Rollup, or Parcel
- as UMD-style loader library like RequireJS
- directly on the server with CommonJS (see our Server Side Rendering docs)
These are ES6 module compatible for tools that support this, such as Rollup. Our icon content packages also support tree shaking which allows compatible tools to remove icons you are not using from your final build.
Comparing Font Awesome (JavaScript) and Font Awesome (JavaScript) SVG Core
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.
One of the most common use cases where you would reach for the core package instead of using fontawesome-free
or fontawesome-pro
is to create a subset of icons to reduce your final bundled file size.
For this case you may still want the <i>
tags to be replaced with <svg>
tags. This is the default behavior when using the CDN or fontawesome-free
and fontawesome-pro
packages. This does not happen automatically when using the core package.
To accomplish this we will use the dom
API.