symfony/web-link
Symfony WebLink component manages typed links between resources and serializes them to HTTP Link headers. Use it to advertise preload, prefetch, and other resource hints for faster navigation and HTTP/2 push, following HTML5 and W3C specs.
Link header to push resources proactively, reducing round trips and improving perceived performance.rel="canonical", rel="next", rel="prev") for pagination, API documentation, or microservices communication.rel="preconnect" or rel="dns-prefetch" to optimize third-party resource loading (e.g., CDNs, analytics).rel="alternate" hreflang), or OpenGraph/Twitter Card links via custom rel types.rel="modulepreload" to prioritize loading JavaScript modules for faster hydration.rel="preload" polyfills instead).<a href> in HTML templates); no HTTP header manipulation is needed.<link> tags in HTML."The Symfony WebLink component is a lightweight, zero-maintenance way to automate performance optimizations like preloading critical assets and enabling HTTP/2 push. By reducing render-blocking delays, we can boost Core Web Vitals scores (LCP, FID) without heavy frontend refactors. It’s a drop-in solution for Laravel/Symfony apps, backed by Symfony’s team—no custom engineering required. Early adopters like [Example Company] saw 20–30% faster page loads for asset-heavy routes. The MIT license and W3C compliance make it risk-free to integrate."
*"This package lets us standardize link headers (preload, prefetch, canonical, etc.) across the app with minimal boilerplate. Key benefits:
rel="preload" to eliminate render-blocking.rel types for SEO, APIs, or custom use cases (e.g., rel="modulepreload" for SPAs).Implementation:
// Preload Bootstrap CSS
$linkProvider = (new GenericLinkProvider())
->withLink(new Link('preload', '/css/bootstrap.min.css', [
'as' => 'style',
'crossorigin' => 'anonymous',
]));
header('Link: ' . (new HttpHeaderSerializer())->serialize($linkProvider->getLinks()));
Next steps: Audit high-traffic routes for render-blocking assets and pilot preload strategies. Pair with Lighthouse audits to measure impact."*
*"Need to optimize page load or standardize API/resource links? This package handles:
✅ Preload/prefetch for assets (CSS, JS, fonts).
✅ HTTP/2 push compatibility.
✅ Canonical/SEO links (e.g., rel="alternate" hreflang).
✅ Custom rel types (e.g., rel="modulepreload" for SPAs).
Why not just use <link> tags?
Getting started:
composer require symfony/web-link
How can I help you explore Laravel packages today?