- How do I install log1x/laravel-webfonts in Laravel?
- Install it with Composer using composer require log1x/laravel-webfonts, then publish the package config if needed and declare the Google Fonts your app uses. Run the package's artisan generation command to download the font files and generate local CSS. Finally, include the generated CSS in your layout, replace Google Fonts CDN link tags, and use the provided Blade component where it fits your templates.
- How do I self-host Google Fonts in Laravel with laravel-webfonts?
- laravel-webfonts downloads the Google Fonts you specify, stores the font files locally, and generates CSS for self-hosting. You then serve the generated assets from your Laravel public directory or a CDN and reference the local CSS instead of fonts.googleapis.com. This removes third-party font requests from the browser and keeps typography privacy-friendly.
- How do I configure which fonts laravel-webfonts downloads?
- After installing the package, publish its configuration and declare the font families, weights, and styles you need there. The overview does not list the exact config keys, so review the published config file and package README for the current schema. Then run the artisan generation command and include the generated CSS.
- How do I preload only specific fonts with laravel-webfonts?
- Version 2.0.1 adds an opt-in ability to preload specific fonts, which affects the generated preload markup and CSS inclusion. Configure the allowlist in the package config and preload only the critical above-the-fold font to avoid wasting bandwidth. Check the generated HTML or your Blade layout to confirm whether the package emits the link rel=preload tags or you need to render them manually.
- Does laravel-webfonts support Laravel 10, 11, and PHP 8?
- The provided overview does not include the exact Laravel and PHP support matrix for the 2.x line. Before installing, check the package composer.json and README for the supported PHP and Laravel versions. The package is designed for Laravel applications and follows standard Composer and config-publishing conventions, but you should verify compatibility for your specific framework version.
- What changed in laravel-webfonts 2.0.1?
- Version 2.0.1 is described as an additive patch that lets you preload specific fonts. The change is opt-in and affects the output layer: generated link rel=preload markup and CSS inclusion. It carries a small review burden, but the larger risks are operational, such as build-time network access and generated asset drift.
- How does laravel-webfonts work with Vite or Laravel Mix asset hashing?
- If you import generated CSS into a Vite or Mix bundle, run font generation before the frontend asset build so the CSS is available to compile. Confirm that any preload URLs point to the final hashed asset paths, not pre-hash filenames. Also review whether generated CSS uses relative or absolute font URLs for your deployment setup.
- Can I run laravel-webfonts in CI without access to Google Fonts?
- The package normally needs build-time network access to Google Fonts to download font files, unless you use a vendored or cached font artifact. Establish generation in CI with either network access or a cached artifact, then commit generated assets or publish them as build artifacts. This avoids environment drift and keeps deployments deterministic.
- Is laravel-webfonts GDPR-friendly for Google Fonts?
- Self-hosting Google Fonts with laravel-webfonts removes browser requests to Google's font CDN, which is the main privacy and GDPR concern for many teams. The package downloads the font files locally and generates CSS you serve yourself, so visitors do not contact Google for typography. You still need to review font licensing and attribution obligations for the fonts you self-host.
- How do I test self-hosted fonts and preload tags in Laravel?
- Load a page in the browser, check the network panel for local font requests, and confirm there are no requests to fonts.googleapis.com or fonts.gstatic.com. Inspect the head for correctly formed preload tags and verify the preloaded font is the critical above-the-fold font. Run Lighthouse or WebPageTest before and after, and test in production-like asset hashing and CSP configurations.