@skelekit/font v0.1.5
@skelekit/font
Optimal fonts for static sites — zero external runtime dependencies.
@skelekit/font is a post-build tool that:
- Scans your static site for font references.
- Downloads them locally if they're external (e.g., Google Fonts).
- Subsets each font to only the characters actually used.
- Generates accurate fallback system fonts to eliminate layout shift (CLS).
- Outputs both WOFF and WOFF2 variants.
- Rewrites your CSS with optimized @font-face rules.
Built entirely with JavaScript — no Python, no native bindings, no external binaries.
Perfect for static site generators like Eleventy, Hugo, Jekyll, and more.
Installation
npm install @skelekit/font
Usage
skelekit-font --site path/to/site
For additional options:
skelekit-font --help
Command-Line Options
--site=path/to/site
: Specify the directory containing your site files.--verbose
: Enable verbose logging.--whitelist-chars=chars
: Specify a string of characters to be included in the font subset even if they are not found in the HTML source. For example,--whitelist-chars=abc
will ensure that the characters 'a', 'b', and 'c' are included in the subset.
Features
Layout Shift Prevention
Skelekit Font automatically adds a system font fallback for each web font that matches the original font's metrics. This prevents layout shifts during font loading by:
- Creating a fallback font-face using Arial with the same metrics as your web font
- Automatically applying this fallback to all font-family declarations
- Using CSS size-adjust and metric overrides to match the system font exactly
For example, if you have:
.title {
font-family: "My Font";
}
It will be transformed to:
.title {
font-family: "My Font", "My Font override";
}
@font-face {
font-family: "My Font override";
src: local("Arial");
ascent-override: 95%;
descent-override: 25%;
line-gap-override: normal;
size-adjust: 100%;
}
This ensures text maintains the same dimensions and layout both before and after the web font loads.
Limitations
- Only processes built, static HTML/CSS/JS — does not support dynamic font loading via JS
- Does not currently support variable fonts (coming soon)
- Font subsetting accuracy may be reduced if text is injected via JS
- Only supports fonts loaded from Google, Bunny CDN, or local.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Code of Conduct
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.
License
This project is licensed under the MIT License - see the LICENSE file for details.