Skip to content

Commit f19129f

Browse files
authored
perf: Replace Font Awesome with inline svg icons (#890)
* perf: Replace Font Awesome with inline svg icons Font Awesome shipped 137 kB of css and eight webfont files for seven glyphs: the external-link arrow, the search magnifier, the glossary link icon and four social icons in the footer. Those are inline svgs now (path data from Font Awesome Free 6.2.1, CC BY 4.0, attributed in ui/NOTICE), sized and colored via a small .svg-icon utility class. site.css shrinks from 146 kB to 48 kB and the webfonts/ directory disappears from the bundle. The fa-* checklist selectors in doc.css stay: they come from upstream and draw the check marks with css content, independent of any icon font. Also removes the inlineDynamicImports rollup option (vite 8 warns it is redundant for non-code-split builds). * perf: Serve the svg icons from a sprite instead of inlining them All seven icons live as symbols in img/icons.svg; usage sites reference them with <use>, which keeps the markup readable and the path data in one reusable, cacheable place. currentColor inheritance works through <use>, so the .svg-icon styling is unchanged. Antora relativizes the root-relative sprite url in page content, so the external-link-icon attribute works from any page depth. The universal-nav partials keep their own pre-existing inline svgs; they can move into the sprite when that area is next touched.
1 parent 678e243 commit f19129f

22 files changed

Lines changed: 51 additions & 7970 deletions

antora-playbook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ asciidoc:
329329
attributes:
330330
base-repo: https://github.com/stackabletech
331331
# an external icon. Create a link opening in a new tab like this: http://my-url.com[Text {external-link-icon}^]
332-
external-link-icon: "<i class=\"fa-solid fa-arrow-up-right-from-square fa-xs\" style=\"margin-left: 3px; vertical-align: baseline;\"></i>"
332+
external-link-icon: "<svg class=\"svg-icon\" style=\"width: 0.75em; height: 0.75em; margin-left: 3px;\" aria-hidden=\"true\"><use href=\"/_/img/icons.svg#icon-external-link\"/></svg>"
333333
# the default caching directory is ./.cache/antora
334334
# Antora caches the git repos, this can sometimes lead to stale content
335335
# use 'make clean' to remove the build and cache directory

local-antora-playbook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ asciidoc:
314314
attributes:
315315
base-repo: https://github.com/stackabletech
316316
# an external icon. Create a link opening in a new tab like this: http://my-url.com[Text {external-link-icon}^]
317-
external-link-icon: "<i class=\"fa-solid fa-arrow-up-right-from-square fa-xs\" style=\"margin-left: 3px; vertical-align: baseline;\"></i>"
317+
external-link-icon: "<svg class=\"svg-icon\" style=\"width: 0.75em; height: 0.75em; margin-left: 3px;\" aria-hidden=\"true\"><use href=\"/_/img/icons.svg#icon-external-link\"/></svg>"
318318
# the default caching directory is ./.cache/antora
319319
# Antora caches the git repos, this can sometimes lead to stale content
320320
# use 'make clean' to remove the build and cache directory

modules/reference/pages/glossary.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
= Glossary
2-
:li: pass:[<i class="fa-solid fa-link fa-sm" style="margin-left: 5px; vertical-align: baseline;"></i>]
2+
:li: pass:[<svg class="svg-icon" style="width: 0.875em; height: 0.875em; margin-left: 5px;" aria-hidden="true"><use href="/_/img/icons.svg#icon-link"/></svg>]
33
:description: Glossary of Stackable terms, including Role, Role Group, and Stacklet, with definitions and links to detailed explanations.
44

55
// refined styling for the glossary

only-dev-antora-playbook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ asciidoc:
107107
attributes:
108108
base-repo: https://github.com/stackabletech
109109
# an external icon. Create a link opening in a new tab like this: http://my-url.com[Text {external-link-icon}^]
110-
external-link-icon: "<i class=\"fa-solid fa-arrow-up-right-from-square fa-xs\" style=\"margin-left: 3px; vertical-align: baseline;\"></i>"
110+
external-link-icon: "<svg class=\"svg-icon\" style=\"width: 0.75em; height: 0.75em; margin-left: 3px;\" aria-hidden=\"true\"><use href=\"/_/img/icons.svg#icon-external-link\"/></svg>"
111111
# the default caching directory is ./.cache/antora
112112
# Antora caches the git repos, this can sometimes lead to stale content
113113
# use 'make clean' to remove the build and cache directory

supplemental-ui/partials/navbar.hbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<a class="navbar-item" href="{{{ relativize (versioned "home" page "reference/index.html") }}}">CRD Reference</a>
1919
{{else}}
2020
<a class="navbar-item" href="{{{ page.attributes.crd-docs }}}" target="_blank">
21-
CRD Reference <i class="fa-solid fa-arrow-up-right-from-square fa-sm" style="margin-left: 5px;"></i>
21+
CRD Reference <svg class="svg-icon" style="width: 0.875em; height: 0.875em; margin-left: 5px;" aria-hidden="true"><use href="{{{uiRootPath}}}/img/icons.svg#icon-external-link"/></svg>
2222
</a>
2323
{{/if}}
2424
<hr class="navbar-divider">
@@ -95,13 +95,13 @@
9595
<a class="navbar-link" href="#">Community</a>
9696
<div class="navbar-dropdown">
9797
<a class="navbar-item" href="https://stackable.tech/en/" target="_blank">
98-
Homepage <i class="fa-solid fa-arrow-up-right-from-square fa-sm" style="margin-left: 5px;"></i>
98+
Homepage <svg class="svg-icon" style="width: 0.875em; height: 0.875em; margin-left: 5px;" aria-hidden="true"><use href="{{{uiRootPath}}}/img/icons.svg#icon-external-link"/></svg>
9999
</a>
100100
<a class="navbar-item" href="https://github.com/stackabletech/" target="_blank">
101-
GitHub <i class="fa-solid fa-arrow-up-right-from-square fa-sm" style="margin-left: 5px;"></i>
101+
GitHub <svg class="svg-icon" style="width: 0.875em; height: 0.875em; margin-left: 5px;" aria-hidden="true"><use href="{{{uiRootPath}}}/img/icons.svg#icon-external-link"/></svg>
102102
</a>
103103
<a class="navbar-item" href="https://discord.com/invite/7kZ3BNnCAF" target="_blank">
104-
Discord <i class="fa-solid fa-arrow-up-right-from-square fa-sm" style="margin-left: 5px;"></i>
104+
Discord <svg class="svg-icon" style="width: 0.875em; height: 0.875em; margin-left: 5px;" aria-hidden="true"><use href="{{{uiRootPath}}}/img/icons.svg#icon-external-link"/></svg>
105105
</a>
106106
<hr class="navbar-divider">
107107
<a class="navbar-item" href="{{{ relativize (versioned "home" page "contributor/index.html") }}}">Contributing</a>

truly-local-playbook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ asciidoc:
7272
attributes:
7373
base-repo: https://github.com/stackabletech
7474
# an external icon. Create a link opening in a new tab like this: http://my-url.com[Text {external-link-icon}^]
75-
external-link-icon: "<i class=\"fa-solid fa-arrow-up-right-from-square fa-xs\" style=\"margin-left: 3px; vertical-align: baseline;\"></i>"
75+
external-link-icon: "<svg class=\"svg-icon\" style=\"width: 0.75em; height: 0.75em; margin-left: 3px;\" aria-hidden=\"true\"><use href=\"/_/img/icons.svg#icon-external-link\"/></svg>"
7676
# the default caching directory is ./.cache/antora
7777
# Antora caches the git repos, this can sometimes lead to stale content
7878
# use 'make clean' to remove the build and cache directory

ui/NOTICE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ header comments; this file preserves the attributions and is included
99
in the published bundle.
1010

1111
- Font Awesome Free 6.2.1 (https://fontawesome.com)
12-
Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License
13-
https://fontawesome.com/license/free
12+
The inline svg icon path data is derived from Font Awesome Free icons
13+
(CC BY 4.0). https://fontawesome.com/license/free
1414
- highlight.js (https://highlightjs.org)
1515
BSD 3-Clause License, (c) 2006 Ivan Sagalaev and contributors
1616
- Asciidoctor Tabs (https://github.com/asciidoctor/asciidoctor-tabs)

ui/build.mjs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Builds the Antora UI bundle (https://docs.antora.org/antora-ui-default/):
2-
// css/, js/, js/vendor/, font/, webfonts/, img/, helpers/, layouts/, partials/
2+
// css/, js/, js/vendor/, font/, img/, helpers/, layouts/, partials/
33
// zipped as build/ui-bundle.zip (the path the playbooks reference).
44
//
55
// The scripts are consumed as classic <script src> tags, so every js entry is
@@ -68,8 +68,7 @@ for (const entry of jsEntries) {
6868
input: entry.input,
6969
output: {
7070
format: 'iife',
71-
entryFileNames: `js/${entry.name}.js`,
72-
inlineDynamicImports: true
71+
entryFileNames: `js/${entry.name}.js`
7372
}
7473
}
7574
}
@@ -89,7 +88,6 @@ await build(
8988
assetFileNames: (asset) => {
9089
const name = asset.names[0] ?? '';
9190
if (name === 'site.css') return 'css/site.css';
92-
if (/^fa-.+\.(woff2?|ttf)$/.test(name)) return 'webfonts/[name][extname]';
9391
if (/\.(woff2?|ttf)$/.test(name)) return 'font/[name][extname]';
9492
if (/\.(svg|png|gif|ico|jpg)$/.test(name)) return 'img/[name][extname]';
9593
return 'css/[name][extname]';
@@ -100,9 +98,7 @@ await build(
10098
})
10199
);
102100

103-
// webfonts/ ships as-is: the Font Awesome css references it with
104-
// runtime-relative urls that vite cannot (and must not) rewrite
105-
for (const dir of ['helpers', 'layouts', 'partials', 'img', 'webfonts']) {
101+
for (const dir of ['helpers', 'layouts', 'partials', 'img']) {
106102
cpSync(resolve(src, dir), resolve(staged, dir), { recursive: true });
107103
}
108104
for (const file of ['NOTICE', 'LICENSE']) {

ui/src/css/base.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,13 @@ body ::-webkit-scrollbar-thumb {
148148
.justify-between {
149149
justify-content: space-between;
150150
}
151+
152+
/* Inline svg icons; the path data comes from Font Awesome Free (CC BY 4.0,
153+
* see ../../NOTICE). Sizes deviating from 1em are set inline at the usage. */
154+
.svg-icon {
155+
display: inline-block;
156+
width: 1em;
157+
height: 1em;
158+
fill: currentcolor;
159+
vertical-align: -0.125em;
160+
}

ui/src/css/site.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@
1919
@import "admonition.css";
2020
@import "end-of-life-banner.css";
2121
@import "link-bar.css";
22-
@import "vendor/fontawesome.css";
2322
@import "@asciidoctor/tabs/dist/css/tabs.css";
2423
@import "tabs.css";

0 commit comments

Comments
 (0)