Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
V

vite-plugin-webfont-dl

> 前端框架
Open source

⚡ Webfont Download Vite Plugin - Effortlessly download and bundle webfonts in your Vite project. Enjoy privacy-first - even offline - development with persisten

380 stars0 likes3 views
WebsiteGitHub

About

⚡ Webfont Download Vite Plugin - Effortlessly download and bundle webfonts in your Vite project. Enjoy privacy-first - even offline - development with persisten

vite-plugin-webfont-dl

Webfont Download — a Vite plugin that downloads webfonts at build time and self-hosts them, eliminating render-blocking requests to third-party font providers.

The plugin collects webfont links, imports, and definitions from your project, downloads the CSS and font files, adds the fonts to your bundle (or serves them through the dev server), and injects the font definitions using a non-render-blocking method.

Features

  • Zero config — automatically detects webfont `` tags, plugin config URLs, and CSS @import statements

  • Self-hosted fonts — font files are bundled with your app; no third-party requests at runtime

  • Non-render-blocking — fonts are injected as an inline `

Method B: Simple config

Extracts, downloads, and injects fonts from the configured webfont CSS URL(s).

  1. Select your font families at your webfont provider and copy the CSS URL(s) from the "Use on the web" code block:

    xml
  2. Pass the CSS URL(s) to the plugin:

    javascript
    // vite.config.js
    import webfontDownload from 'vite-plugin-webfont-dl';
    
    export default {
      plugins: [
        webfontDownload([
          'https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap',
          'https://fonts.googleapis.com/css2?family=Fira+Code&display=swap',
        ]),
      ],
    };

That's all!

Whichever method you chose, the result is the same: the webfonts are downloaded, self-hosted, and injected — ready to use on both the local development server and in production builds:

css
h1 {
  font-family: 'Press Start 2P', cursive;
}

h2 {
  font-family: 'Fira Code', monospace;
}

Import alias: the plugin can be imported under any of these names: webfontDownload, webfontDl, viteWebfontDl, ViteWebfontDownload, or viteWebfontDownload.

Laravel

To use with the Laravel Vite Plugin, add this line to your Blade file:

blade
@vite('webfonts.css')

…


**Or**, when using the dev server or the `injectAsStyleTag: false` option:

```html

What happens on the client side:

  1. Fonts load directly from the embedded CSS (`` tag). Or:
  2. The first line instructs the browser to prefetch the CSS file for later use as a stylesheet. [preload]
  3. The second line loads the CSS file as a print stylesheet (non-render-blocking), then promotes it to an all media stylesheet once loaded, by removing the media attribute. [stylesheet]

Benchmark

Comparison using a starter Vite project:

Standard Google Fonts vite-plugin-webfont-dl
webfont.feat.agency webfont-dl.feat.agency
PageSpeed Insights PageSpeed Insights

Resources

  • Page Speed Checklist / Fix & Eliminate Render Blocking Resources

License

MIT License © 2022–present feat.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptfontsgoogle-fontsgooglefontslaravel

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架